Four-round bug
(Turn http://www.nssoft.net/showdoc.asp?did=267) Keywords: round
Delphi's four round-entered functions Round has bugs and cannot work properly. For XXX.5, the integer part is an odd number, then Round Up, even the number Round Down, for example: x: = round (17.5) = x = 18 x: = round (12.5) = x = 12 Please use the following function instead Round: function DoRound (Value: Extended): Int64; procedure Set8087CW (NewCW: Word); asm MOV Default8087CW, AX FNCLEX FLDCW Default8087CW end; const RoundUpCW = $ 1B32; var OldCW: Word; begin OldCW: = Default8087CW; try SET8087CW (Roundupcw); Result: = ROUND (value); Finally Set8087cw (OLDCW); end;