It would appear to be a "bankers rounding" problem, so pay attention to what

John Treder told you.

There is a version of ROUND that does not use banker's rounding, but I

cant't search the Delphi help on this system as it doesn't have Delphi

installed. Check the Delphi Wiki and you will find it, or someone else will

tell us directly what its name is.

Looked it up myself:

System.Round

From RAD Studio API Documentation

Returns the value of X rounded to the integer number.

In Delphi, the Round function rounds a real-type value to an integer-type

value.

X is a real-type expression. Round returns an Int64 value that is the value

of X rounded to an integer number. The default Rounding mode is rmNearest.

If X is exactly halfway between two integer numbers, the result is always

the even number. This method of rounding is often called "Banker's

rounding."

If the rounded value of X is not within the Int64 range, a run-time error is

generated that can be handled using the EInvalidOp exception.

Note: The behavior of Round can be affected by the Set8087CW procedure or

System.Math.SetRoundMode function.

See Also

a.. System.Int

b.. System.Trunc

c.. System.Set8087CW

d.. System.Math.SetRoundMode

e.. System.Math.RoundTo

f.. System.Math.SimpleRoundTo

g.. Delphi Intrinsic Routines

h.. Mathematical Routines

i.. About Floating-Point Arithmetic

j.. Floating point precision control (Delphi for x64) ({$EXCESSPRECISION})

Code Examples

a.. SystemRound (Delphi)

b.. SetRoundMode (Delphi)

c.. SystemCos (Delphi)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Note the following comment elsewhere in the help:

SimpleRoundTo is the traditional "Round off" that was learned at

school.

--

JF

Connect with Us