Actually, the rule is round to the nearest integer if there is one. If

there are two integers equally near, pick the even one. This logic is

commonly used to reduce the effect of cumulative rounding errors and is

common in the sciences. If you want a more consistent rule, use

Int(x+0.5). If you are using currency types, make sure all values and

variables in your expression are currency type to prevent

least-significant-bit problems converting between binary floating point and

decimal fixed point.

Rounding can actually be a pretty complicated subject at times. For

accounting purposes, it is often necessary to do rounding which is +/-

symmetric which can be done by rounding the absolute value of a number,

then restoring the sign.

Round .5s to higher magnitude: Int( Abs(x)+CCur(.5) ) * Sgn(x)

Round .5s to lower magnitude: Int( -Abs(x)+CCur(.5) ) * -Sgn(x)

--

Developer: Inter-Tec Software Services

( Remove ".NOSPAM" from address to reply via e-mail )

Quote:

> > Why does CInt(0.5) return 0, CINt(1.5) return 2 and CInt(2.5) return 2?

> > Help file says it rounds to nearest. Is this the 'new math' I've been

> > hearing about?

> I believe the rule is "rounding to the nearest =even= number".

> --

> National Library of Canada

> Anti spam note: Do not Reply without correcting the address

> ** None of the above has any official status **