# RE: Very odd behaviour in Mod/

```
I would like to be able to do the following:

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

In[18]:= N[t,3]
Out[18]= 4.83677

Where the correct value is:
4.831039164951128133.......

If you want to be sure even a few digits are right, you can currently
use N[t,17].
Then Mathematica will go to all the trouble to get 17 digits correct,
when you only care about a few of them.

Ted Ersek
----------
|From: "megalith"@jimc.demon.co.uk@PMDF@PAXMB1 To:
mathgroup@smc.vnet.net
|To: ersek ted; "mathgroup"@smc.vnet.net@PMDF@PAXMB1 |Subject: [mg12133] [mg12048]
Very odd behaviour in Mod/N |Date: Friday, April 24, 1998 8:57AM |
|<<File Attachment: 00000000.TXT>>
|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,