Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: sub as mathematical function

by vr (Curate)
on Sep 04, 2019 at 21:04 UTC ( [id://11105630]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11105630]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-24 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found