MathGroup Archive 2007

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

Search the Archive

Re: strange bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79161] Re: [mg79126] strange bug?
  • From: Curtis Osterhoudt <cfo at lanl.gov>
  • Date: Fri, 20 Jul 2007 03:20:28 -0400 (EDT)
  • Organization: LANL
  • References: <200707190731.DAA01633@smc.vnet.net>
  • Reply-to: cfo at lanl.gov

It happens in 6.0.0, too. Must be an accumulator/inexact arithmetic thing. If 
you instead add 1/10 (instead of 0.1) to i in each loop, you'll get what you 
expected.



On Thursday 19 July 2007 01:31:31 Jeremy Price wrote:
> I think I've found a bug in mathematica 5.2,
>
> In[418]:=
> $Version
>
> Out[418]=
> 5.2 for Microsoft Windows (June 20, 2005)
>
> When I run, eg,
>
> In[416]:= IntegerPart[10*5.1]
>
> Out[416]= 51
>
> I get what I expect.  But when I run the same thing in a loop,
>
> For[n = 1, n < 20, n = n + .1,
>   Print[n, " ", IntegerPart[10*n]]
>   ]
>
> I get output like:
> >From In[415]:= 4.2 42
> >
> >From In[415]:=4.3 43
> >
> >From In[415]:=4.4 44
> >
> >From In[415]:=4.5 45
> >
> >From In[415]:=4.6 46
> >
> >From In[415]:=4.7 47
> >
> >From In[415]:=4.8 48
> >
> >From In[415]:=4.9 48
> >
> >From In[415]:=5. 49
> >
> >From In[415]:=5.1 50
> >
> >From In[415]:=5.2 51
>
> Any idea what's going on here or how to fix it?



-- 
==========================================================
Curtis Osterhoudt
cfo at remove_this.lanl.and_this.gov
PGP Key ID: 0x4DCA2A10
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
==========================================================


  • References:
  • Prev by Date: Slow Manipulate with image argument
  • Next by Date: Re: Re: fast way of appending x zeros to a list?
  • Previous by thread: strange bug?
  • Next by thread: Graph, amplitude problem