In gsl-shell ( a luajit based interface to gsl), I got
> 0/0==0/0
true
while it is false from Lua 5.1.
Why is it? Does this discrepancy come from Luajit vs Lua, GSL library, or the gsl-shell interface?
Quick testing indicates that this is gsl-shell. lua5.1 and lua5.2 (from debian), lua 5.1 (self-compiled on CentOS 5) and luajit (from git master, self-compiled on debian) all give the proper behaviour (and return nan when the result of 0/0 is printed directly. The current build of gsl-shell (for Windows) has the behaviour you indicated and returns -2147483648 when the result of 0/0 is printed.
I can't explain it (or even theorize about it really) but it certainly seems to be a gsl-shell problem.
Asked on gsl-shell mailing list. found that
That's because gsl-shell is compiled with the -ffast-math flag, which(surprisingly!) disables nans and infs.1
Per GCC manual, I guess this option should not be turned on for such a numerical application like GSL-Shell.
*-ffast-math Sets -fno-math-errno, -funsafe-math-optimizations, -fno-trapping-math, -ffinite-math-only, -fno-rounding-math, -fno-signaling-nans and fcx-limited-range. This option causes the preprocessor macro FAST_MATH to be defined. This option should never be turned on by any -O option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ISO rules/specifications for math functions.*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With