[ic] Vend::Util::round_to_frac_digits() precision issue
Brian J. Miller
brian at endpoint.com
Wed Sep 2 14:15:39 UTC 2009
I've been messing with the oft seen issue of rounding floats in Perl and
noticed that the round_to_frac_digits() method can't handle
"exponentized" (word?) numbers. Basically it just returns the original
because the regex can't handle the number. The attached patch handles
this case by assuming we are close enough to zero to not care (I
suppose for correctness it should examine $digits to make that
judgement) and returns 0 in this case. A number recognized as before
should be handled as before. Anything else I've added a warning for, but
otherwise handle as before (aka returning what was given).
I don't know if this is a consequence of my Perl build, 64 bit OS, a
newer Perl version, or what. I'll leave that to the experts to suss out.
Example failure numbers:
Thoughts? I can push via Github if that is preferred.
More information about the interchange-users