Code: Select all
CG-USER(9): (+ 2.32 0.001)
2.3209999
What is the proper way to correctly display 2.321 ?
Code: Select all
CG-USER(9): (+ 2.32 0.001)
2.3209999
Code: Select all
(format t "~,5f" (+ 2.32 0.001))
-> 2.32100
If you want exact rationals, use exact rationals.hajovonta wrote:Maybe it was my high expectations
Code: Select all
CL-USER> (+ 232/100 1/1000)
2321/1000
Code: Select all
(float (+ 232/100 1/1000))
-> 2.321
Technically, that (somewhat) reintroduces the problem...Konfusius wrote:You can convert rationals to floats:Code: Select all
(float (+ 232/100 1/1000)) -> 2.321
Code: Select all
L> (format t "~E" (float (+ 232/100 1/1000)))
2.3210001e+0
NIL
L> (= 2.3210001 (float (+ 232/100 1/1000)))
T
Code: Select all
L> (ql:quickload "wu-decimal")
; Loading "wu-decimal"
[package wu-decimal]...
("wu-decimal")
L> (wu-decimal:enable-decimal-printing-for-ratios)
NIL
L> (format t "~A" (+ 232/100 1/1000))
2.321
NIL