MathGroup Archive 1998

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

Search the Archive

Very odd behaviour in Mod/N

Hi there,
I've observed some very odd behaviour when using Mod and N. It seems
that, when handling very large numbers, Mathematica (3.0.1, Win32) does
not display machine-precision results correctly. Here's an example
which behaves as it should:

In[12]:= Q = 10^8
Out[12]= 100000000

In[13]:= t = Mod[Q, 2 Pi]
Out[13]= 100000000 - 31830988 Pi

In[14]:= N[t]
Out[14]= 1.9427

In[15]:= N[t, 20]
Out[15]= 1.9426951345040144600

Now for a very similar example which obviously behaves wrongly:

In[16]:= Q = 10^18
Out[16]= 1000000000000000000

In[17]:= t = Mod[Q, 2 Pi]
Out[17]= 1000000000000000000 - 318309886183790670 Pi

In[18]:= N[t]
Out[18]= 128.

In[19]:= N[t, 20]
Out[19]= 4.831039164951128133

What exactly is going on here?

Thanks, cheers,
Adrian Cable.

  • Prev by Date: RE: Output of Animate to AVI
  • Next by Date: Re: Pattern matching more than once
  • Prev by thread: Questions about "collecting" complex exponentials and simplifying expressions
  • Next by thread: Re: Very odd behaviour in Mod/N