in reply to Math::SnapTo
In the CB, tye suggested the following change in snap_units() to avoid potential rounding errors:
from:
to:my $factor = 1/$units;
my $factor = int( 1/$units + 0.5 );
The drawback is that for fractional cases, $units must be 1/N, where N is an integer. I'm not super clear on the potential rounding errors; nor am I clear on the potential utility of arbitrary $units. Perhaps certain people can elucidate for our edification.
Matt
P.S. For some prior discussion of this stuff, check out Fix floats like you do in your head.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Math::SnapTo
by tachyon (Chancellor) on Dec 27, 2002 at 07:35 UTC |