rjbs / Number-Tolerant

perl library for numbers with built-in tolerances
3 stars 4 forks source link

intersection() fails when first value is zero #6

Closed mjcarman closed 9 years ago

mjcarman commented 9 years ago

When the value of the first argument to intersection() is zero, it's min/max value is being lost. e.g.

my $min   = Number::Tolerant->new(0 => 'or_more');
my $max   = Number::Tolerant->new(10 => 'or_less');
my $range = $min & $max;
say $range; # prints 'x <= 10' instead of '0 <= x <= 10'

This happens because the method is using a boolean OR (||) to find the min/max values instead of checking for definedness. If the first value is boolean false, the second (non-existent) value is taken.

rjbs commented 9 years ago

fixed by #7