GNU bug report logs - #16987
Bad default mantissa width for ~g format string

Previous Next

Package: guile;

Reported by: David Kastrup <dak <at> gnu.org>

Date: Tue, 11 Mar 2014 13:41:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: David Kastrup <dak <at> gnu.org>
To: 16987 <at> debbugs.gnu.org
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




This bug report was last modified 11 years and 97 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.