Exp in SBCL is wrong?

CL-USER> (exp 1)
2.7182817

Why? This should be 2.7182818 (rounded from 2.7182818284590452353602874713526624977572470936999595749669 ...)

SBCL 1.0.29.11.debian

+4
source share
2 answers

This is a rounding error inherent in the IEEE single-threaded format.

CL-USER> (exp 1.0d0) 2.718281828459045d0 
+8
source

Learn more about floating point arithmetic and its "problems" in this classic article (PDF):

What Every Computer Scientist Should Know About Floating-Point Arithmetic

+3
source

Source: https://habr.com/ru/post/1336636/


All Articles