This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: [Ask for help]: Met a problem with strtof
- From: Mark Brown <ms_brown at sbcglobal dot net>
- To: Wang Weidong <wangweidong1 at huawei dot com>
- Cc: libc-help at sourceware dot org
- Date: Thu, 24 Apr 2014 16:21:55 -0500
- Subject: Re: [Ask for help]: Met a problem with strtof
- Authentication-results: sourceware.org; auth=none
- References: <53566C6A dot 4050804 at huawei dot com> <5358058F dot 9010806 at sbcglobal dot net> <5358691A dot 1090104 at huawei dot com>
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