hedgewars/uFloat.pas
changeset 4436 94c948a92759
parent 4415 941251bad467
child 4900 8ad0e23e6d63
equal deleted inserted replaced
4366:d19adc635c99 4436:94c948a92759
    60 function Distance(const dx, dy: hwFloat): hwFloat;
    60 function Distance(const dx, dy: hwFloat): hwFloat;
    61 function DistanceI(const dx, dy: LongInt): hwFloat;
    61 function DistanceI(const dx, dy: LongInt): hwFloat;
    62 function AngleSin(const Angle: Longword): hwFloat;
    62 function AngleSin(const Angle: Longword): hwFloat;
    63 function AngleCos(const Angle: Longword): hwFloat;
    63 function AngleCos(const Angle: Longword): hwFloat;
    64 function SignAs(const num, signum: hwFloat): hwFloat; inline;
    64 function SignAs(const num, signum: hwFloat): hwFloat; inline;
       
    65 function hwSign(r: hwFloat): LongInt; inline;
    65 
    66 
    66 {$IFDEF FPC}
    67 {$IFDEF FPC}
    67 {$J-}
    68 {$J-}
    68 {$ENDIF}
    69 {$ENDIF}
    69 {$WARNINGS OFF}
    70 {$WARNINGS OFF}
   145 {$IFNDEF FPC}
   146 {$IFNDEF FPC}
   146 type hwFloat = Extended;
   147 type hwFloat = Extended;
   147 {$ENDIF}
   148 {$ENDIF}
   148 
   149 
   149 implementation
   150 implementation
   150 //uses uMisc;
   151 uses uSinTable;
   151 
   152 
   152 
   153 
   153 {$IFDEF FPC}
   154 {$IFDEF FPC}
   154 
   155 
   155 function int2hwFloat (const i: LongInt) : hwFloat;
   156 function int2hwFloat (const i: LongInt) : hwFloat;
   340 begin
   341 begin
   341 SignAs.QWordValue:= num.QWordValue;
   342 SignAs.QWordValue:= num.QWordValue;
   342 SignAs.isNegative:= signum.isNegative
   343 SignAs.isNegative:= signum.isNegative
   343 end;
   344 end;
   344 
   345 
   345 {$INCLUDE "SinTable.inc"}
   346 function hwSign(r: hwFloat): LongInt;
       
   347 begin
       
   348 // yes, we have negative zero for a reason
       
   349 if r.isNegative then hwSign:= -1 else hwSign:= 1
       
   350 end;
       
   351 
   346 
   352 
   347 function AngleSin(const Angle: Longword): hwFloat;
   353 function AngleSin(const Angle: Longword): hwFloat;
   348 begin
   354 begin
   349 {$IFDEF DEBUGFILE}
   355 {$IFDEF DEBUGFILE}
   350 //TryDo((Angle >= 0) and (Angle <= 2048), 'Sin param exceeds limits', true);
   356 //TryDo((Angle >= 0) and (Angle <= 2048), 'Sin param exceeds limits', true);