Perl Monk, Perl Meditation | |
PerlMonks |
Re^3: Split range 0 to M into N non-overlapping (roughly equal) ranges.by JavaFan (Canon) |
on Mar 13, 2011 at 11:08 UTC ( [id://892939]=note: print w/replies, xml ) | Need Help?? |
Yeah, they are rounding errors. Rearranging the calculation fixes it (at least, on my platform):
The most important is the final ($_+1)/$N*($M+1) - that should return $M+1 for $_ == $N-1. The impact of other rounding errors is that a range is 1 shorter than expected (but making the next one one larger - it shouldn't skip numbers).
In Section
Seekers of Perl Wisdom
|
|