newLISP Fan Club

Forum => newLISP in the real world => Topic started by: dexter on December 25, 2012, 12:31:22 AM

Title: format %e problem
Post by: dexter on December 25, 2012, 12:31:22 AM
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
Title: Re: format %e problem
Post by: johu on December 25, 2012, 01:32:21 AM
> (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 format (//http).
Title: Re: format %e problem
Post by: HPW on December 25, 2012, 01:51:23 AM
(format "%e" 123456789)

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

(Not mentioned in the doc)
Title: Re: format %e problem
Post by: dexter on December 25, 2012, 05:24:22 AM
oh God



thanks guys