format %e problem

Started by dexter, December 25, 2012, 12:31:22 AM

Previous topic - Next topic

dexter

Hi guys



in newlisp docs



(format "%e" 123456789)        → "1.234568e+08"


But when I reverse this

> (int 1.234568e+08)
123456800


Got the different results

Why is this happend?



---

newLISP v.10.4.4 on OSX IPv4/6. 64bits

johu

#1
> (format "%e" 123456789)
"1.234568e+008"
> (format "%.6e" 123456789)
"1.234568e+008"
> (int 1.234568e+008)
123456800
> (format "%.7e" 123456789)
"1.2345679e+008"
> (int 1.2345679e+008)
123456790
> (format "%.8e" 123456789)
"1.23456789e+008"
> (int 1.23456789e+008)
123456789

Please read http://www.newlisp.org/downloads/newlisp_manual.html#format">format.

HPW

#2
(format "%e" 123456789)

Without precision parameter it uses a default precision, so t gets rounded.

(Not mentioned in the doc)
Hans-Peter

dexter

#3
oh God



thanks guys