3 ms·
The numeric tower in Common Lisp may surprise us with simple things as addition: (+ #c(10 -1) #c(20 1)) the result of adding these two complex numbers is th
by lispm 3y ago
The numeric tower in Common Lisp may surprise us with simple things as addition:
(+ #c(10 -1) #c(20 1))
the result of adding these two complex numbers is the integer 30.
- Paul-Craft 3y agoHuh. I did not know that. I am surprised that it actually coerces the result to an integer, although that's certainly an artificial type edge case. SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. * (+ #c(10 -1) #c(20 1)) 30 * (type-of (+ #c(10 -1) #c(20 1))) (INTEGER 0 4611686018427387903) For example, if you do this, you do get a complex number. * (type-of (+ #c(10 -1) #c(20 1.0))) (COMPLEX (SINGLE-FLOAT 0.0 30.0))