-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Float literal 17.328679084777833f0
is not correctly rounded
#49689
Comments
This is probably due to the fact that we performed rounding twice. Lines 278 to 281 in 7ef78e4
xref: #5988 #include <stdlib.h>
#include <stdio.h>
int main()
{
const char* str;
char* stopstring;
float ff;
double dd;
str = "17.328679084777833";
ff = strtof(str, &stopstring);
dd = strtod(str, &stopstring);
printf("string = %s\n", str);
printf("strtod = %f\n", dd);
printf("strtof = %f\n", ff);
printf(" d->f = %f\n", (float)dd);
} out
test with
|
yeah, that's just broken. why do we do it that way? |
Good news: windows now includes the Bad news: mingw's float _strtof_l( const char *nptr, char **endptr, _locale_t _Locale)
{
const double ret = _strtod_l(nptr, endptr, _Locale); Note the commit time: So we still need a precise implementation of |
That seems more-or-less what everyone does. For example, here's the source for gdtoa-strtof from Apple (gdtoa is the upstream distribution that most *nix seem to use): https://opensource.apple.com/source/Libc/Libc-391/gdtoa/FreeBSD/gdtoa-strtof.c.auto.html |
Closing now that JuliaSyntax is the default parser (which rounds this correctly). |
17.328679084777833f0
is not correctly rounded when parsed by the Julia parser:Noticed over at JuliaLang/JuliaSyntax.jl#134 (comment)
I haven't dug deep into whatever the problem is here (likely in the flisp
read
code), but the float literal parsing in JuliaSyntax.jl avoids whatever it is by callingjl_strtof_c
directly. We see:CC @oscardssmith
The text was updated successfully, but these errors were encountered: