Re: How to coerce a real to an integer in X?
Re: How to coerce a real to an integer in X?
- Subject: Re: How to coerce a real to an integer in X?
- From: email@hidden
- Date: Fri, 1 Feb 2002 02:48:18 -0500
On Thu, 31 Jan 2002 22:18:58 -0500, "Bob.Kalbaugh" <email@hidden>
asked,
>
And what's up with this?
>
>
(3.5)
>
integer result
>
--> 4
>
>
(4.5)
>
integer result
>
--> 4 (???)
>
>
(5.5)
>
integer result
>
--> 6
>
>
(6.5)
>
integer result
>
--> 6 (???)
This is the IEEE Floating Point standard's rounding rules, which are to round a
value that is exactly half way between two points so that the resulting least
significant digit is even. This way, half the rounding is up, and half the
rounding is down, and you have no bias to the error. IEEE Floating Point is how
the PowerPC chip is hardwired.
The Standard Additions 'round' command provides other options, like "as taught
in school", which always round dddd.5 up.
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden