hedgewars/uFloat.pas
branchwebgl
changeset 8026 4a4f21070479
parent 7715 8b653edac2a2
child 8847 ff7fbab7cd56
equal deleted inserted replaced
8023:7de85783b823 8026:4a4f21070479
    53     case byte of
    53     case byte of
    54     0: (Round, Frac: Longword);
    54     0: (Round, Frac: Longword);
    55     1: (QWordValue : QWord);
    55     1: (QWordValue : QWord);
    56     end;
    56     end;
    57 {$ENDIF}
    57 {$ENDIF}
    58 
    58 		  
    59 // Returns an hwFloat that represents the value of integer parameter i
    59 // Returns an hwFloat that represents the value of integer parameter i
    60 function int2hwFloat (const i: LongInt) : hwFloat; inline;
    60 function int2hwFloat (const i: LongInt) : hwFloat; inline;
    61 function hwFloat2Float (const i: hwFloat) : extended; inline;
    61 function hwFloat2Float (const i: hwFloat) : extended; inline;
    62 
    62 
    63 // The implemented operators
    63 // The implemented operators
   219 hwFloat2Float:= i.Frac / $100000000 + i.Round;
   219 hwFloat2Float:= i.Frac / $100000000 + i.Round;
   220 if i.isNegative then
   220 if i.isNegative then
   221     hwFloat2Float:= -hwFloat2Float;
   221     hwFloat2Float:= -hwFloat2Float;
   222 end;
   222 end;
   223 
   223 
   224 {$IFNDEF WEB}
   224 {$IFNDEF WEBGL}
   225 operator = (const z1, z2: hwFloat) z : boolean; inline;
   225 operator = (const z1, z2: hwFloat) z : boolean; inline;
   226 begin
   226 begin
   227     z:= (z1.isNegative = z2.isNegative) and (z1.QWordValue = z2.QWordValue);
   227     z:= (z1.isNegative = z2.isNegative) and (z1.QWordValue = z2.QWordValue);
   228 end;
   228 end;
   229 
   229 
   299         b:= false
   299         b:= false
   300     else
   300     else
   301         b:= (z1.QWordValue > z2.QWordValue) <> z2.isNegative
   301         b:= (z1.QWordValue > z2.QWordValue) <> z2.isNegative
   302 end;
   302 end;
   303 {$ENDIF}
   303 {$ENDIF}
   304 {$IFDEF WEB}
   304 {$IFDEF WEBGL}
   305 (*
   305 (*
   306     Mostly to be kind to JS as of 2012-08-27 where there is no int64/uint64.  This may change though.
   306     Mostly to be kind to JS as of 2012-08-27 where there is no int64/uint64.  This may change though.
   307 *)
   307 *)
   308 operator = (const z1, z2: hwFloat) z : boolean; inline;
   308 operator = (const z1, z2: hwFloat) z : boolean; inline;
   309 begin
   309 begin