[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: RDP%alan.kahuna.decnet.lockheed.com@RELAY.CS.NET*Subject*: Why is there no REAL number data type?*From*: Hunter Barr <barr@BBN.COM>*Date*: Mon, 29 Jan 90 17:23:49 EST*Cc*: slug@WARBUCKS.AI.SRI.COM*In-reply-to*: "RDP%ALAN.kahuna.decnet.lockheed.com %ALAN.kahuna.DECNET.LOCKHEED.COM"@warbucks.ai.sri.com's message of Mon, 29 Jan 90 14:18:15 CST <9001292018.AA26282@diamond.STC.LOCKHEED.COM>

The term "Real Number" has a very precise meaning mathematically, and the designers of Common Lisp are right not to abuse it, as has been done in some other languages. Remember that, where numerical computation is concerned, computers are *finite* state machines, and so they cannot represent any real numbers which are not rational, at least not in any format which can be reconciled with rationals for computation. So for purposes of numerical computation, we are limited to a subset of the reals, the rationals, and it is right to call them that. For some rationals it is convenient to represent them as terminating, floating-point "decimals", which come close enough to reals for most needs. Thus we always use 3.14159 or 22/7 for the real number pi. When this is not good enough, programs like MACSYMA to do what we humans do by hand, i.e. do algebra with symbols to represent reals like pi until they are forced to do numerical computation, at which point they substitute 3.14159 for the symbol "pi". If this still bothers you, look at it this way: we cannot represent all the integers as fixnums (although we do a good practical imitation using bignums). We can only represent fixnums which fit in a certain range (and bignums must fit in available memory). We simply cannot represent integers that are arbitrarily positive or arbitrarily negative without resorting to the trick in the above paragraph. Likewise we cannot represent all the reals, because we do not have infinite precision on our floats-- the "decimals" must terminate before we run out of addressable memory. In practice we limit them to a certain size, like 32 bits. Now, can anyone tell me why Common Lisp floating-point numbers are not considered a subset of rationals? I find that (rationalp 22/7) => t and (rationalp 22) => t but (rationalp 22.7) => nil ______ HUNTER

**Follow-Ups**:**Why is there no REAL number data type?***From:*Barry Margolin <barmar@THINK.COM>

**References**:**Why is there no REAL number data type?***From:*"RDP%ALAN.kahuna.decnet.lockheed.com %ALAN.kahuna.DECNET.LOCKHEED.COM"@WARBUCKS.AI.SRI.COM

- Prev by Date:
**Why is there no REAL number data type?** - Next by Date:
**THE database book? books for Statice users** - Previous by thread:
**Why is there no REAL number data type?** - Next by thread:
**Why is there no REAL number data type?** - Index(es):