Re: Ceiling & Floor

*To*: mathgroup at yoda.physics.unc.edu*Subject*: Re: Ceiling & Floor*From*: David Withoff <withoff>*Date*: Wed, 25 Mar 1992 22:01:03 -0600

> I am running Mathematica 2.0 on a Sparcstation 1+. > > Ceiling[10^30 + 3.333] returns 1000000000000000019884624838656 > > Similarly for Floor[]. Is this a known bug? > > Ferrell Wheeler > wheeler at super.org One useful thing that Ceiling[10^30 + 3.333] could do is generate a warning message. The only meaningful ceiling of 10^30+3.333 is buried in the uncertainty of the number. A similar problem occurs with Floor, Round, and Mod: In[6]:= Mod[10^30 + 3.333, 2] Out[6]= 0. An elegant implementation of such a message is a bit tricky, since it isn't easy to tell when the last few bits of an inexact number represent integer differences. If we are satisified with a certain amount of numerical fuzz it's not too bad. Roughly (very roughly!) : In[17]:= Ceiling[e_Real] := $Failed /; Log[10, e] > $MachinePrecision In[18]:= Ceiling[10^30 + 3.333] Out[18]= $Failed Other suggestions? Dave Withoff withoff at wri.com