[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exponential number



On Thursday 27 May 2004 05:21 am, soo wrote:
> The following seems to be a bug of FORMAT.
>
> > (round 1.23e20)
>
> 1.23e+20
>
> > (format "~0,3F" 1.23e20)
>
> "1.230e+20"
>
> > (round 1.23e-20)
>
> 0.0
>
> > (format "~0,3F" 1.23e-20)
>
> "0.000"

Why do you think the above is a bug? What do you think is wrong?

The numbers you specified above both show 3 digits after the decimal point, as 
requested.

The number near zero shows its leading digits as "0.000" as expected.

SRFI-48 states:
===========

If d is specified, the number is processed as if added to 0.0, i.e. it is 
converted to an inexact value. 

(format "~8,2F" 1/3) => "    0.33"

Digits are padded to the right with zeros 

(format "~8,2F" 32) => "   32.00"

If the number it too large to fit in the width specified, a string longer than 
the width is returned 

(format "~1,2F" 4321) => "4321.00"

For very large or very small numbers, the point where exponential notation is 
used is implementation defined. 

(format "~8F" 32e5) => "   3.2e6" or "3200000.0"

===========

Cheers,
-KenD