``` Subject: Re: Request of information about Lisp From: rpw3@rigden.engr.sgi.com (Rob Warnock) Date: 3 Jul 2001 03:25:49 GMT Newsgroups: comp.lang.lisp Message-ID: <9hrdvt\$gdqg\$1@fido.engr.sgi.com> ```
```<Gareth.McCaughan@pobox.com> replied to "Luigi":
+---------------
|   - Integers in Lisp do not overflow. If you multiply
|     1000000000 by 1000000000, you get 1000000000000.
|     (In C++, you are more likely to get 3567587328.)
+---------------

Actually, Luigi, I think Gareth left off a few zeros:  ;-}  ;-}

> (* 1000000000 1000000000)
1000000000000000000
>

But the basic point is valid. Lisp provides arbitrary-precision
"bignums" (big integers) and arbitrary-precision rational numbers
(a ratio of two integers), so integer arithmetic is neither truncated
at some arbitrary 32- or 64-bit boundary, nor are fractions forced to
"zero" or floating-point (unless you *tell* them to be):

> (/ 15.0 25.0)
0.6
> (/ 15 25)
3/5
> (defvar a 163477937096098716906480)
A
> (defvar b 83374438621927341066528)
B
> (* a b)
13629881232457981255816665236528107508034301440
> (/ a b)
4278751255/2182181218
> (gcd a b)
38206927057296
> (lcm a b)
356738483888492081107219718492640
> (+ 3/5 5/7)
46/35
> (+ 46/35 7/11)
751/385
> (float 751/385)
1.9506494
> (truncate 751/385)
1 ;			; integer quotient
366/385			; rational remainder
>

It also provides floating point numbers (usually in several precisions)
and complex numbers (whose real and imaginary parts may be integers,
rationals, or floats).

> (* #c(5 2) #c(1 -1))
#C(7 -3)
> (+ #c(3/5 1/2) #c(5 2))
#C(28/5 5/2)
> (* #c(5.0 2.0) (sqrt -1))
#C(-2.0 5.0)
> (imagpart (/ #c(5.0 2.0) (sqrt -1)))
-5.0
>

-Rob

-----
Rob Warnock, 31-2-510		<rpw3@sgi.com>
SGI Network Engineering		<http://reality.sgi.com/rpw3/> [until 8/15]
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA

[Note: aaanalyst@sgi.com and zedwatch@sgi.com aren't for humans ]

```