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: libc-help at sourceware dot org
- Date: Wed, 23 Apr 2014 13:25:19 -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>
Hello-
While I am not a true floating point expert, it would help to know:
What headers you are including (for example, are you using <stdlib.h>)?
What compile options are you using (for example, on the older gcc, are
you using -std=c99 )?
On 04/22/2014 08:19 AM, Wang Weidong wrote:
> Hi,
>
> I test the code below :
> -------------------------------------------------------------
> int main() {
>
> char *str1="-0x1.4EF009P-16";
> char *str2="-0x1.744513P-55";
> char *str3="+0x1.1C7509P-19";
> float temp;
>
> fesetround(FE_UPWARD);
>
> temp = strtof(str1, NULL);
> printf(" %s -> %a\n", str1, temp);
>
> fesetround(FE_DOWNWARD);
>
> temp = strtof(str2, NULL);
> printf("%s -> %a\n", str2, temp);
> temp = strtof(str3, NULL);
> printf("%s -> %a\n", str3, temp);
> return 0;
> }
>
> -------------------------------------------------------------
>
> 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
>
> All the fesetround setted success.
> Can someone tell me which is right and why?
--
Mark Brown
ms_brown@sbcglobal.net