MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Why Round[5/2]=2?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17505] Re: [mg17469] Why Round[5/2]=2?
  • From: BobHanlon at aol.com
  • Date: Mon, 10 May 1999 19:53:14 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 5/9/99 12:49:59 PM, xingjing at calvin.math.vt.edu writes:

>While  I am working on the exercises on the book _Power Programming
>with Mathematica_ I noticed that Round[5/2] gave me 2. It is obviously
>wrong. But how could this happen? I am using Mathematica 3.0.1 on a
>Macintosh. I also tried the command"Round[5/2]" on other Macintoshes
>and PCs and all them gave me 2. Is this some kind bug? Other numbers I
>tried gave me the answers I expected. 
>
>Can some one tell me what is going on?
>

The convention with which I am familiar is that you round numbers that are 
half integers to the nearest even integer.  As with the example that you 
gave, Mathematica conforms to that convention.

Table[{N[(2k+1)/2], Round[(2k+1)/2]}, {k, -9, 9}]

{{-8.5, -8}, {-7.5, -8}, {-6.5, -6}, {-5.5, -6}, {-4.5, -4}, 
  {-3.5, -4}, {-2.5, -2}, {-1.5, -2}, {-0.5, 0}, {0.5, 0}, 
  {1.5, 2}, {2.5, 2}, {3.5, 4}, {4.5, 4}, {5.5, 6}, 
  {6.5, 6}, {7.5, 8}, {8.5, 8}, {9.5, 10}}

Bob Hanlon


  • Prev by Date: Re: AND... How can I tell M to have the same spaces on the x- AND the y-axis?
  • Next by Date: Re: exporting graphics as eps
  • Previous by thread: Re: Why Round[5/2]=2?
  • Next by thread: Re: Why Round[5/2]=2?