Subject: lib/32951: printf(3) "%.*f" display problem for some numbers with 0 precision
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <njoly@pasteur.fr>
List: netbsd-bugs
Date: 02/28/2006 10:25:00
>Number: 32951
>Category: lib
>Synopsis: printf(3) "%.*f" display problem for some numbers with 0 precision
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Feb 28 10:25:00 +0000 2006
>Originator: Nicolas Joly
>Release: NetBSD 3.99.15
>Organization:
Insitut Pasteur, Paris.
>Environment:
System: NetBSD calamity.sis.pasteur.fr 3.99.15 NetBSD 3.99.15 (CALAMITY) #9: Mon Feb 27 16:40:49 CET 2006 njoly@calamity.sis.pasteur.fr:/local/src/NetBSD/obj/i386/sys/arch/i386/compile/CALAMITY i386
Architecture: i386
Machine: i386
>Description:
I just discovered, a small printf(3) family functions problem when trying to
display some float numbers with 0 precision. With numbers in ]0.0;0.5], the
resul has an extra period `.' where it should not.
This effect can be easily seen :
njoly@calamity [XFree86/xc]> sysstat -w 1 vm
[...]
Namei Sys-cache Proc-cache FPU synch IPI 497 ndcpy
Calls hits % hits % 98 TLB shootdown I 296 fltcp
31229 30234 97 8 0. cpu1 softnet 5913 zfod
100 cpu1 timer 59 cow
[...]
>How-To-Repeat:
njoly@calamity [tmp/sysstat]> cat xx.c
#include <stdio.h>
int main() {
float f;
for (f = 0.0; f < 1.2; f += 0.1) {
printf("%f ... %.*f\n", f, 0, f); }
return 0; }
njoly@calamity [tmp/sysstat]> cc xx.c
njoly@calamity [tmp/sysstat]> ./a.out
0.000000 ... 0
0.100000 ... 0.
0.200000 ... 0.
0.300000 ... 0.
0.400000 ... 0.
0.500000 ... 0.
0.600000 ... 1
0.700000 ... 1
0.800000 ... 1
0.900000 ... 1
1.000000 ... 1
1.100000 ... 1
>Fix: