Exact real numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg50501] Exact real numbers
- From: Ross Sean Civ AFRL/DELO <sean.ross at kirtland.af.mil>
- Date: Wed, 8 Sep 2004 05:15:01 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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
- Follow-Ups:
- Re: Exact real numbers
- From: DrBob <drbob@bigfoot.com>
- Re: Exact real numbers
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Exact real numbers