- Code: Select all
CG-USER(9): (+ 2.32 0.001)
2.3209999
I have Allegro Common Lisp, 9.0, Windows 7 machine.
What is the proper way to correctly display 2.321 ?
CG-USER(9): (+ 2.32 0.001)
2.3209999
(format t "~,5f" (+ 2.32 0.001))
-> 2.32100
hajovonta wrote:Maybe it was my high expectations
CL-USER> (+ 232/100 1/1000)
2321/1000
(float (+ 232/100 1/1000))
-> 2.321
Konfusius wrote:You can convert rationals to floats:
- Code: Select all
(float (+ 232/100 1/1000))
-> 2.321
L> (format t "~E" (float (+ 232/100 1/1000)))
2.3210001e+0
NIL
L> (= 2.3210001 (float (+ 232/100 1/1000)))
T
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
Users browsing this forum: No registered users and 12 guests