# HG changeset patch # User unc0rr # Date 1366199113 -14400 # Node ID 71485c03a507d37db304c6de346690bf6c69ffdf # Parent 36e1574e989d20c942c8e15e36c99e1dd16aadcd hwFloat division is ~1.6 times faster now diff -r 36e1574e989d -r 71485c03a507 hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Wed Apr 17 12:11:33 2013 +0400 +++ b/hedgewars/uFloat.pas Wed Apr 17 15:45:13 2013 +0400 @@ -318,19 +318,18 @@ z.isNegative:= z1.isNegative xor z2.isNegative; z.Round:= z1.QWordValue div z2.QWordValue; t:= z1 - z2 * z.Round; -if t.QWordValue = 0 then - z.Frac:= 0 -else +z.Frac:= 0; + +if t.QWordValue <> 0 then begin - while ((t.QWordValue and $8000000000000000) = 0) and ((z2.QWordValue and $8000000000000000) = 0) do + while ((t.QWordValue and $FF00000000000000) = 0) and ((z2.QWordValue and $FF00000000000000) = 0) do begin - t.QWordValue:= t.QWordValue shl 1; - z2.QWordValue:= z2.QWordValue shl 1 + t.QWordValue:= t.QWordValue shl 8; + z2.QWordValue:= z2.QWordValue shl 8 end; + if z2.Round > 0 then - z.Frac:= (t.QWordValue) div (z2.Round) - else - z.Frac:= 0 + inc(z.QWordValue, t.QWordValue div z2.Round); end end;