hedgewars/uFloat.pas
changeset 5151 cbadb9fa52fc
parent 5124 84267f79879b
child 5192 881c14f81d12
equal deleted inserted replaced
5150:63ad8a648afd 5151:cbadb9fa52fc
    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 
    62 
    62 // The implemented operators
    63 // The implemented operators
    63 
    64 
    64 operator + (const z1, z2: hwFloat) z : hwFloat; inline;
    65 operator + (const z1, z2: hwFloat) z : hwFloat; inline;
    65 operator - (const z1, z2: hwFloat) z : hwFloat; inline;
    66 operator - (const z1, z2: hwFloat) z : hwFloat; inline;
   186 int2hwFloat.isNegative:= i < 0;
   187 int2hwFloat.isNegative:= i < 0;
   187 int2hwFloat.Round:= abs(i);
   188 int2hwFloat.Round:= abs(i);
   188 int2hwFloat.Frac:= 0
   189 int2hwFloat.Frac:= 0
   189 end;
   190 end;
   190 
   191 
       
   192 function hwFloat2Float (const i: hwFloat) : extended;
       
   193 begin
       
   194 hwFloat2Float:= i.QWordValue / $100000000;
       
   195 if i.isNegative then hwFloat2Float:=hwFloat2Float*-1;
       
   196 end;
       
   197 
   191 operator + (const z1, z2: hwFloat) z : hwFloat;
   198 operator + (const z1, z2: hwFloat) z : hwFloat;
   192 begin
   199 begin
   193 if z1.isNegative = z2.isNegative then
   200 if z1.isNegative = z2.isNegative then
   194    begin
   201    begin
   195    z.isNegative:= z1.isNegative;
   202    z.isNegative:= z1.isNegative;