This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/303] New: scanf into single rounds in 2.3.3 (truncates in 2.3.1)
- From: "d dot bullivant at auckland dot ac dot nz" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 6 Aug 2004 04:05:56 -0000
- Subject: [Bug libc/303] New: scanf into single rounds in 2.3.3 (truncates in 2.3.1)
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
When reading into a single with %f, scanf now rounds (2.3.3) whereas it used to
truncate (2.3.1) - see program below.
Could you please confirm that this is an intentional change.
*******************************************************************************
FILE : scanf_double.c
LAST MODIFIED : 5 August 2004
DESCRIPTION:
Code for testing reading doubles into singles.
BUILD:
gcc scanf_double.c -o scanf_double
OUTPUT:
glibc-2.3.1
single 5 7e2fe
double 5 7e2fe81f74638
difference 1.93664e-06
glibc-2.3.3
single 5 7e2ff
double 5 7e2fe81f74638
difference -1.87805e-06
==============================================================================*/
#include <ieee754.h>
main(int argc,char **argv)
{
char *string_double="0.3397167399474852E+02";
double d;
float f;
union ieee754_double *d_ptr;
union ieee754_float *f_ptr;
d_ptr=(union ieee754_double *)&d;
f_ptr=(union ieee754_float *)&f;
sscanf(string_double,"%f",&f);
sscanf(string_double,"%lf",&d);
printf("single %lx
%lx\n",(f_ptr->ieee).exponent-127,(f_ptr->ieee).mantissa);
printf("double %lx %llx\n",(d_ptr->ieee).exponent-1023,
((long long unsigned)((d_ptr->ieee).mantissa0)*0x100000000ll+
(long long unsigned)((d_ptr->ieee).mantissa1))*0x8ll);
printf("difference %g\n",d-(double)f);
}
--
Summary: scanf into single rounds in 2.3.3 (truncates in 2.3.1)
Product: glibc
Version: 2.3.3
Status: NEW
Severity: minor
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: d dot bullivant at auckland dot ac dot nz
CC: glibc-bugs at sources dot redhat dot com
http://sources.redhat.com/bugzilla/show_bug.cgi?id=303
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.