GNU GCC does not round floating-point divisions to the nearest value
1–10 of 87 posts
Re: GNU GCC does not round floating-point divisions to the nearest value
#2Re: GNU GCC does not round floating-point divisions to the nearest value
#3Edit: Also, curiously, things worked as expected for me using -std=gnu11. This was a fairly old version of GCC though, things might have changed.
Re: GNU GCC does not round floating-point divisions to the nearest value
#4This seems like a property of the Intel 8087 math coprocessor and its distant descendants found in x86 chips, not anything to do with gcc?
Re: GNU GCC does not round floating-point divisions to the nearest value
#5This seems like a property of the Intel 8087 math coprocessor and its distant descendants found in x86 chips, not anything to do with gcc?
EDIT: GCC gets it wrong with -O0 (when it's evaluated at runtime) and right with -O2 (when it evaluates it at compile time)
Clang appears to get it right when evaluated at compile time or runtime.
Clang uses the divsd instruction; GCC uses the fdiv instruction – so this really is SSE vs x87 FPU.
Re: GNU GCC does not round floating-point divisions to the nearest value
#6Re: GNU GCC does not round floating-point divisions to the nearest value
#7This seems like a property of the Intel 8087 math coprocessor and its distant descendants found in x86 chips, not anything to do with gcc?
But then why does python and JavaScript on the same machines get it right?