Re: Exact real numbers

*To*: mathgroup at smc.vnet.net*Subject*: [mg50525] Re: Exact real numbers*From*: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>*Date*: Thu, 9 Sep 2004 05:17:43 -0400 (EDT)*Organization*: Universitaet Leipzig*References*: <chmntb$9sf$1@smc.vnet.net>*Reply-to*: kuska at informatik.uni-leipzig.de*Sender*: owner-wri-mathgroup at wolfram.com

Hi, machine numbers on a binary computer are stored as a linear combination of powers of 2. Numbers with a finite number of figures in the decimal system must not have a finite number of figures in the binary system. A conversion between base 10 and binary numbers can't be symmetric because the conversion process would be only symmetric when you computer can store an infinte long sequence of binary numbers. You can go to a computer store and buy infinte many RAM, insert it into your computer and build an operating system that can address this RAM and than store your infinte long binaries. Fortunately with your infinte RAM you can store an infinte number of those numbers. But the conversion back to the decimal system may take some time. The second best solution is to build a new FPU that work not with binary numbers and uses 10 as base. Regards Jens Ross Sean Civ AFRL/DELO wrote: > > I have been having an on-going problem with real numbers in Mathematica that > has come up again. In short, I can find no way of "rounding" a number in > Mathematica. To me, when I say, round 1.56012309843 to three decimal > places, I want the result to be 1.560 exactly. No hanging 00000000001's . > The reason for this is that I need to do 3-D logic involving the location of > points in space. I don't like getting faked out by numbers that ought to be > the same but are slighly unequal due to rounding errors. > > Round only applies to integers. Multiplying the results of Round by machine > precision reals results in all the hanging digits I want to get rid of. > > SetPrecision and SetAccuracy don't seem to do what I want. > SetPrecision[1.5000287965,5] returns a result with more than 5 digits to the > right of the decimal as does SetAccuracy. > > RealDigits is great in that I can actually get a list of all digits and > manipulate them, however, its "inverse" FromDigits returns an F**ing > fraction. I don't want a fraction. I want an exact decimal. I also prefer > function pairs that are exact inverses to one another. > > One strange assymetry of Mathematica is that I can type in the exact decimal > number 1.50027` and Mathematica knows that is an exact decimal. FullForm > reveals that the only decimal digits in that number are what I specified. > However, I know of no way to create an exact decimal from a machine > precision one. > > Does anyone know of a way to do true decimal rounding in Mathematica? > > Please respond to sean.ross at kirtland.af.mil. I no longer subscribe to > mathgroup. > > Dr. Sean Ross > AFRL/DELO > 3550 Aberdeen Ave SE, Building 761 > Kirtland AFB, NM 87117 > > phone: 505-846-9148 > fax: 505-853-0485