On 01/01/2013 12:36 PM, mfl...@racket-lang.org wrote:
07d5a9e Matthew Flatt <mfl...@racket-lang.org> 2013-01-01 12:31 : | fix `expt' on small negative number and large positive odd | | The pow() function apparently gets it wrong on some platforms. | | Closes PR 13391
Thanks, Matthew. I'm looking forward to getting bugged by DrDr less. :D One question about the fix:
src/racket/src/number.c ~~~~~~~~~~~~~~~~~~~~~~~ --- OLD/src/racket/src/number.c +++ NEW/src/racket/src/number.c @@ -2729,7 +2729,16 @@ static double sch_pow(double x, double y) return scheme_infinity_val; } } else { - return protected_pow(x, y); + double r; + r = protected_pow(x, y); + if ((r == 0.0) && !minus_zero_p(r)) { + /* check large odd power of a small negative number, + which some libraries get wrong for some reason */ + if ((x < 0) && (fmod(y, 2.0) == 1.0)) { + r = scheme_floating_point_nzero; + } + } + return r; } } #endif
I looked into fixing this myself, and identified this as a spot to change. I also saw some JIT-looking stuff for `flexpt' that looked kind of like it was machine code, so I didn't try to fix it. Does this code you just changed get compiled during the build and then inlined by the JIT?
Neil ⊥ _________________________ Racket Developers list: http://lists.racket-lang.org/dev