equal
deleted
inserted
replaced
128 {$IFNDEF FPC} |
128 {$IFNDEF FPC} |
129 type hwFloat = Extended; |
129 type hwFloat = Extended; |
130 {$ENDIF} |
130 {$ENDIF} |
131 |
131 |
132 implementation |
132 implementation |
133 uses uConsts; |
133 uses uConsts, uMisc; |
134 |
134 |
135 {$IFDEF FPC} |
135 {$IFDEF FPC} |
136 |
136 |
137 function int2hwFloat (const i: LongInt) : hwFloat; |
137 function int2hwFloat (const i: LongInt) : hwFloat; |
138 begin |
138 begin |
284 function hwSqrt(const t: hwFloat): hwFloat; |
284 function hwSqrt(const t: hwFloat): hwFloat; |
285 var l, r: QWord; |
285 var l, r: QWord; |
286 c: hwFloat; |
286 c: hwFloat; |
287 begin |
287 begin |
288 hwSqrt.isNegative:= false; |
288 hwSqrt.isNegative:= false; |
289 l:= 0; |
289 |
290 r:= t.QWordValue div 2 + 1; |
290 if t.Round = 0 then |
|
291 begin |
|
292 l:= t.QWordValue; |
|
293 r:= $100000000 |
|
294 end else |
|
295 begin |
|
296 l:= $100000000; |
|
297 r:= t.QWordValue |
|
298 end; |
|
299 |
291 repeat |
300 repeat |
292 c.QWordValue:= (l + r) div 2; |
301 c.QWordValue:= (l + r) div 2; |
293 if hwSqr(c).QWordValue > t.QWordValue then r:= c.QWordValue else l:= c.QWordValue |
302 if hwSqr(c).QWordValue > t.QWordValue then r:= c.QWordValue else l:= c.QWordValue |
294 until r - l <= 1; |
303 until r - l <= 1; |
|
304 |
295 hwSqrt.QWordValue:= l |
305 hwSqrt.QWordValue:= l |
296 end; |
306 end; |
297 |
307 |
298 function Distance(const dx, dy: hwFloat): hwFloat; |
308 function Distance(const dx, dy: hwFloat): hwFloat; |
299 begin |
309 begin |