(floor 13158008.6) 13158009 It should be 13158008. Same with truncate.
It's not the FLOOR function which rounds up, it's the parsing of the number:
(rationalize 13158008.6) => 13158009 read-default-float-format => SINGLE-FLOAT
It you want more than 6 digits of precision with floating-point numbers, you need to force double-precision, either explicitly
(floor 13158008.6d0) => 13158008 ; 0.599999999627471d0
or by changing read-default-float-format :
(setq read-default-float-format 'double-float) => DOUBLE-FLOAT (floor 13158008.6) => 13158008 ; 0.599999999627471d0
Log in to post a comment.
It's not the FLOOR function which rounds up, it's the parsing of the number:
(rationalize 13158008.6) => 13158009
read-default-float-format => SINGLE-FLOAT
It you want more than 6 digits of precision with floating-point numbers, you need to force double-precision, either explicitly
(floor 13158008.6d0) => 13158008 ; 0.599999999627471d0
or by changing read-default-float-format :
(setq read-default-float-format 'double-float) => DOUBLE-FLOAT
(floor 13158008.6) => 13158008 ; 0.599999999627471d0