hedgewars/uFloat.pas
changeset 8919 67214340fa53
parent 8917 263f2a8475bc
child 8921 e5db2a42e7e8
equal deleted inserted replaced
8918:512753ea4b1b 8919:67214340fa53
   311 z.isNegative:= z1.isNegative xor (z2 < 0);
   311 z.isNegative:= z1.isNegative xor (z2 < 0);
   312 z.QWordValue:= z1.QWordValue * abs(z2)
   312 z.QWordValue:= z1.QWordValue * abs(z2)
   313 end;
   313 end;
   314 
   314 
   315 operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; inline;
   315 operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; inline;
   316 var t: hwFloat;
   316 var t: QWord;
   317 begin
   317 begin
   318 if z2.QWordValue = 0 then inc(z2.QWordValue);
   318 if z2.QWordValue = 0 then inc(z2.QWordValue);
   319 z.isNegative:= z1.isNegative xor z2.isNegative;
   319 z.isNegative:= z1.isNegative xor z2.isNegative;
   320 z.Round:= z1.QWordValue div z2.QWordValue;
   320 z.Round:= z1.QWordValue div z2.QWordValue;
   321 t:= z1 - z2 * z.Round;
   321 t:= z1.QWordValue - z2.QWordValue * z.Round;
   322 z.Frac:= 0;
   322 z.Frac:= 0;
   323 
   323 
   324 if t.QWordValue <> 0 then
   324 if t <> 0 then
   325     begin
   325     begin
   326     while ((t.QWordValue and $FF00000000000000) = 0) and ((z2.QWordValue and $FF00000000000000) = 0) do
   326     while ((t and $FF00000000000000) = 0) and ((z2.QWordValue and $FF00000000000000) = 0) do
   327         begin
   327         begin
   328         t.QWordValue:= t.QWordValue shl 8;
   328         t:= t shl 8;
   329         z2.QWordValue:= z2.QWordValue shl 8
   329         z2.QWordValue:= z2.QWordValue shl 8
   330         end;
   330         end;
   331         
   331         
   332     if z2.Round > 0 then
   332     if z2.Round > 0 then
   333         inc(z.QWordValue, t.QWordValue div z2.Round);
   333         inc(z.QWordValue, t div z2.Round);
   334     end
   334     end
   335 end;
   335 end;
   336 
   336 
   337 operator / (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline;
   337 operator / (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline;
   338 begin
   338 begin