CINT and Integer Assignments Round x.5 to Nearest Even Integer (42732)
This article was previously published under Q42732
SUMMARY
When a numeric expression ending in .5 is assigned to an integer
variable, the binary (b) math version of Macintosh QuickBASIC will
round the expression to the nearest even integer. For example, .5
converts to 0, 1.5 converts to 2, 2.5 converts to 2, and 3.5 converts
to 4 [in both compiled and interpreted binary (b) math programs].
This rounding to the nearest even integer occurs for the CINT function
and for an integer division assigned to an integer variable. This
behavior is a feature of the IEEE Floating Point Standard.
In contrast, the Decimal Math version [Microsoft QuickBASIC (d) or
Microsoft BASIC (d)] always rounds numbers ending in .5 upward when
assigned to integer variables. You can choose the math package that
best suits your needs.
Modification Type: |
Minor |
Last Reviewed: |
1/8/2003 |
Keywords: |
KB42732 |
|