• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to coerce a real to an integer in X?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How to coerce a real to an integer in X?
      • From: email@hidden (Michael Sullivan)
    • Re: How to coerce a real to an integer in X?
      • From: "Bob.Kalbaugh" <email@hidden>
  • Prev by Date: Re: Week of year - odd/even week
  • Next by Date: Re: How to coerce a real to an integer in X?
  • Previous by thread: Re: How to coerce a real to an integer in X?
  • Next by thread: Re: How to coerce a real to an integer in X?
  • Index(es):
    • Date
    • Thread