Bug#687545: libc6: Incorrect decimal printf output of tiny long double values on PowerPC
Package: libc6
Version: 2.13-35
Severity: normal
The minimum positive long double value is not output correctly by
printf with the decimal conversion specifiers (e, f, g) on PowerPC
(where long double is implemented with a double-double arithmetic).
See the testcase below. There may be the same problem with other
tiny values.
#include <stdio.h>
#include <math.h>
int main (void)
{
double d;
long double e;
d = nextafter (0.0, 1.0);
printf ("d = %e = %f = %g = %a\n", d, d, d, d);
e = d;
printf ("e = %Le = %Lf = %Lg = %La\n", e, e, e, e);
d = e;
printf ("d = %e = %f = %g = %a\n", d, d, d, d);
printf ("d = %.330f\n", d);
printf ("e = %.330Lf\n", e);
return 0;
}
I get:
d = 4.940656e-324 = 0.000000 = 4.94066e-324 = 0x0.0000000000001p-1022
e = 4.450148e-308 = 0.000000 = 4.45015e-308 = 0x0.0000000000001p-1022
d = 4.940656e-324 = 0.000000 = 4.94066e-324 = 0x0.0000000000001p-1022
d = 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656
e = 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044501477170144027661805
Note that 4.450148e-308 / 4.940656e-324 is about 2^53, where 53 is the
precision of a double. I suspect that the glibc code doesn't handle
small values such that one of the double's in the representation is 0.
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (900, 'testing'), (900, 'stable'), (200, 'unstable')
Architecture: powerpc (ppc)
Kernel: Linux 2.6.26-1-powerpc
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages libc6 depends on:
ii libc-bin 2.13-35
ii libgcc1 1:4.7.1-7
libc6 recommends no packages.
Versions of packages libc6 suggests:
ii debconf [debconf-2.0] 1.5.46
pn glibc-doc <none>
ii locales 2.13-35
-- debconf information:
glibc/upgrade: true
glibc/disable-screensaver:
* glibc/restart-failed:
* glibc/restart-services: spamassassin openbsd-inetd exim4 cron atd
* libraries/restart-without-asking: true
-- debsums errors found:
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 5250 package 'inn2':
missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 8462 package 'libgdbmg1':
missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 11058 package 'libnewt0':
missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 13393 package 'docbook-mathml':
missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 22784 package 'libpcd':
missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 31190 package 'inn2-inews':
missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 33324 package 'libisc4':
missing architecture
dpkg-divert: warning: parsing file '/var/lib/dpkg/status' near line 5250 package 'inn2':
missing architecture
dpkg-divert: warning: parsing file '/var/lib/dpkg/status' near line 8462 package 'libgdbmg1':
missing architecture
dpkg-divert: warning: parsing file '/var/lib/dpkg/status' near line 11058 package 'libnewt0':
missing architecture
dpkg-divert: warning: parsing file '/var/lib/dpkg/status' near line 13393 package 'docbook-mathml':
missing architecture
dpkg-divert: warning: parsing file '/var/lib/dpkg/status' near line 22784 package 'libpcd':
missing architecture
dpkg-divert: warning: parsing file '/var/lib/dpkg/status' near line 31190 package 'inn2-inews':
missing architecture
dpkg-divert: warning: parsing file '/var/lib/dpkg/status' near line 33324 package 'libisc4':
missing architecture
Reply to: