bug-guile
[Top][All Lists]
Advanced

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

bug#16987: Bad default mantissa width for ~g format string


From: David Kastrup
Subject: bug#16987: Bad default mantissa width for ~g format string
Date: Tue, 11 Mar 2014 14:40:40 +0100

scheme@(guile-user)> (format #f "~g" (/ 1e100 3))
$19 = 
"3333333333333333000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0
    "

That, frankly, is pretty ludicrous.  The reserved mantissa width should
at least be constrained to the actually available precision of the data
type.  If it isn't, there is no useful way to output a variable with
minimal width.  Using ~S instead results in the much more reasonable
"3.333333333333333e99" but it will not convert fractions to a floating
point representation:

scheme@(guile-user)> (format #f "~g" (/ 10000000000000000000000000000000 3))
$22 = "3333333333333333600000000000000.0    "
scheme@(guile-user)> (format #f "~S" (/ 10000000000000000000000000000000 3))
$23 = "10000000000000000000000000000000/3"
scheme@(guile-user)> 

-- 
David Kastrup





reply via email to

[Prev in Thread] Current Thread [Next in Thread]