in reply to Re^5: Comparing a value to a list of numbers
in thread Comparing a value to a list of numbers
> plus I imagine certain set operations would be problematic due to floating-point inaccuracies.
I doubt this, rounding errors happen only after arithmetic operations
I was thinking something like:
$ perl -MSet::IntSpan -le 'print Set::IntSpan->new("1-10")->complement +->run_list' (-0,11-)
What's the equivalent with floating-point? Does the lower range end at 0.9, 0.99, 0.999, 0.9999, ...? I know there's probably a mathematically valid answer, but I wonder how it would be represented as a floating-point number.
Another one:
use Set::IntSpan; my $set = Set::IntSpan->new('3-12,25-30,42'); for ( my $el=$set->first; defined $el; $el=$set->next ) { print "$el\n"; }
Workarounds would be possible, like telling the iterator what size steps it should take.
I'm not the module's author, so I can't tell you any more "why" and "why not" :-) It's probably possible to write a similar module that handles floats, but Set::IntSpan isn't it ;-)
Update: And, of course it's possible to work with decimals if you multiply them by the appropriate factors, like how I work with milliseconds instead of seconds in Determining Gaps and Overlap in Timestamped Data.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Comparing a value to a list of numbers (updated)
by syphilis (Archbishop) on Feb 02, 2021 at 01:38 UTC | |
by haukex (Archbishop) on Feb 03, 2021 at 10:48 UTC | |
|
Re^7: Comparing a value to a list of numbers (floats)
by LanX (Saint) on Feb 01, 2021 at 18:36 UTC |