MathGroup Archive 2004

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

Search the Archive

Re: bug in IntegerPart ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47758] Re: bug in IntegerPart ?
  • From: Jon Harrop <jdh30 at cam.ac.uk>
  • Date: Sun, 25 Apr 2004 05:13:32 -0400 (EDT)
  • Organization: University of Cambridge
  • References: <c6d8hl$jhl$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Dennis de Lang wrote:
> Why does the following happen?

You have specified numbers in floating point arithmetic. Floating point
arithmetic is not exact. Specifically, in this case, the first expression
actually evaluates to slighly under 50:

In  := (1.65 - 1.3)/0.007 // FullForm
Out := 49.999999999999986`

Of course, if you use exact arithmetic, such as rational arithmetic, this
doesn't happen:

In  := (165/100 - 13/10)/(7/1000)
Out := 50

Cheers,
Jon.


  • Prev by Date: RE: bug in IntegerPart ?
  • Next by Date: Re: bug in IntegerPart ?
  • Previous by thread: RE: bug in IntegerPart ?
  • Next by thread: Re: bug in IntegerPart ?