I want to Round(-0.0066219357357)
and it gives -1
.
Isn't it supposed to be 0
? And what can I use to round it correctly?
UPDATE: the number is a result of (LineDirection.X/distance); where LineDirection.X is an integer and Distace is double.
Looking into System.pas from XE, all work is done by FISTP instruction:
procedure _ROUND;
asm
...
FISTP qword ptr [ESP]
...
end;
According to the Intel's Instruction Reference, value "is rounded to an integer value, according to the rounding mode specified by the RC field of the FPU control word"
So, I would advise you to check if this RC field of FPU control word is set to the rounding you need.
You can do this by working with whole control word - see Set8087CW, and related xxxx8087CW
procedures/functions, with Default8087CW variable.
Or you can try Math.SetRoundMode, as @Uwe Raabe suggested. Your case sounds like either rmUp or rmTruncate rmDown
was used.
Theoretically, your CPU can be the reason as well, however, it hardly so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With