in reply to Re: sub as mathematical function
in thread sub as mathematical function
Measure (and cost) of returning "exactly the same" result unspecified, a pedant would note it's pure luck and coincidence that for 9 intervals these functions indeed seem to always return the same. For a simple case of 6 intervals:
~$ perl -E 'say 4 if 0.8333333333333333 < 5/6' 4 ~$ perl -E 'say int 6 * 0.8333333333333333' 5
For maybe general case of 100 intervals, playing with Data::Float (and from similar experiment literal number above came from):
~$ perl -MData::Float=nextdown -E '$n=100; for(1..$n){say if $_-1 != i +nt $n*nextdown $_/$n}' 5 10 17 20 23 34 40 46 67 68 80 81 92 93
|
---|
In Section
Seekers of Perl Wisdom