This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Ask for help]: Met a problem with strtof


On 04/23/2014 08:30 PM, Wang Weidong wrote:
> I use `gcc -std=c99 -lm test.c -o test` to compile it.
> then do it `./test`

Do you see different results when you put the library flag at the end,
to help the linker resolve things, like:
   gcc -std=c99 test.c -o test -lm

That said.....

> I met a problem as below:
> On SUSE-SP1 x86_64 with glibc-2.11-3 and gcc-4.3.2
> I got the result:
> 
> -0x1.4EF009P-16 -> -0x1.4ef00ap-16
> -0x1.744513P-55 -> -0x1.744514p-55
> +0x1.1C7509P-19 -> 0x1.1c750ap-19
> 
> while On Fedora x86_64 with glibc-2.17-19 and gcc-4.8.2
> I got the result:
> 
> -0x1.4EF009P-16 -> -0x1.4ef008p-16
> -0x1.744513P-55 -> -0x1.744512p-55
> +0x1.1C7509P-19 -> 0x1.1c7508p-19

gcc did not have a lot of C99 (or IEEE 754) support in it before 4.6;
also it depends on how well floating point is supported on the hardware
in question (and the glibc level of course, all software has bugs :-) .

For what it's worth, I'm seeing results similar to your Fedora output on
my system (Ubuntu 14.04, gcc 4.9, libc 2.19). My compile line is
    gcc -std=c99 rounding.c -o rounding -lm
I have also taken the liberty of adding
    #pragma STDC FENV_ACCESS ON
at the start of the file, but I'm unsure if that is really supported in
gcc (yet).



-- 
Mark Brown
ms_brown@sbcglobal.net


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]