Re: Ceiling & Floor
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re: Ceiling & Floor
- From: keiper
- Date: Thu, 26 Mar 92 09:09:26 CST
> Ceiling[10^30 + 3.333] returns 1000000000000000019884624838656
This is NOT a bug.
In[3]:= 10^30 + 3.333
30
Out[3]= 1. 10
In[4]:= MachineNumberQ[%]
Out[4]= True
In[5]:= $NumberBits[%%]
Out[5]= {1, {}, {1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0,
> 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0,
> 0, 1, 1, 1, 0, 1, 0, 1, 0, 0}, 100}
In[6]:= SetPrecision[%%%, 40]
30
Out[6]= 1.000000000000000019884624838656 10
Arithmetic with machine numbers results in machine numbers (unless the result
can't be expressed as a machine number due to overflow or underflow.)
53 or 64 (or whatever your machine happens to use) bits is insufficient
to give any digits to the right of the decimal point. Ceiling[ ] and Floor[ ]
have nothing to do with it.
Jerry B. Keiper
keiper at wri.com