On Sat, Dec 11, 1999 at 06:55:55PM +0000, Na'im Tyson wrote: > > I'm having some problems using Math::BigFloat. I was using it for a > research project, but I had to come up with another quick fix. In any > event, my problem is that the following subroutine returns 0 and position > blank. For each comparison that's made, 0 continues to be the largest, > which shouldn't be the case. > > Now, I'm sure that the problem lies w/ myself, however, I don't know that > it is. If anyone has any suggestions, please let me know. I'm not so sure, actually. This appears to be a bug in Math::BigFloat. Here are two of the values you're comparing: 0.0009 is +9E-4. 0 is +0E+0. Here's Math::BigFloat::fcmp() : # compare 2 values returns one of undef, <0, =0, >0 # returns undef if either or both input value are not numbers sub fcmp #(fnum_str, fnum_str) return cond_code { local($x, $y) = (fnorm($_[$[]),fnorm($_[$[+1])); if ($x eq "NaN" || $y eq "NaN") { undef; } else { ord($y) <=> ord($x) || ( local($xm,$xe,$ym,$ye) = split('E', $x."E$y"), (($xe <=> $ye) * (substr($x,$[,1).'1') || Math::BigInt::cmp($xm,$ym)) ); } } The line ($xe <=> $ye) * (substr($x,$[,1).'1') compares the exponents of the two values; because 0 is greater than -4, fcmp determines incorrectly that +0E+0 is greater than +9E-4. Math::BigFloat's documentation is rather intriguing: BUGS The current version of this module is a preliminary version of the real thing that is currently (as of perl5.002) under development. even in the Math::BigFloat bundled with 5.005_03. Apparently Math::BigFloat was never fully developed. Ronald # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org