Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: bug in IntegerPart ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47748] Re: bug in IntegerPart ?
  • From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
  • Date: Sun, 25 Apr 2004 05:13:20 -0400 (EDT)
  • References: <c6d8hl$jhl$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Dennis de Lang" <lang.NO at science.uva.nl> wrote:
> Why does the following happen?
>
> In[1]:= (1.65 - 1.3)/0.007
> Out[1]:= 50.
> In[2]:= IntegerPart[%]
> Out[2]:= 49

This is not Mathematica's fault.

In[3]:= FullForm[Out[1]]

Out[3]//FullForm= 49.999999999999986`

It is inherently perilous to use "approximate real" numbers, like 1.65, in
situations like this in which discontinuous functions, such as IntegerPart,
are involved.

Instead, I suggest

In[4]:= (165/100 - 13/10)/(7/1000)

Out[4]= 50

In[5]:= IntegerPart[%]

Out[5]= 50

HTH,
David

> but:
>
> In[1]:= 0.35/0.007
> Out[1]:= 50.
> In[2]:= IntegerPart[%]
> Out[2]:= 50
>
> I'm puzzled....
> - Dennis


  • 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 ?