2010/10/16

Fast replacement for Round() function

//This function using FPU to perform fast rounding operation
function FastRound(const Value : Double): Integer; assembler; register; const
c : Int64 = $18000000000000; // 2^52 + 2^51
var
x: Double; i: Integer absolute x;
asm
fild c fadd Value fstp x mov eax, i
end;

1 comment: