Four-round bug

xiaoxiao2021-03-06  64

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;

转载请注明原文地址:https://www.9cbs.com/read-86540.html

New Post(0)