Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: finding the correct integer

by johngg (Canon)
on Nov 30, 2020 at 14:57 UTC ( #11124397=note: print w/replies, xml ) Need Help??


in reply to finding the correct integer

Using int will truncate so if the result, due to the inexact way a computer will represent 0.0001, is, say, 6504.9999997 it will end up as 6504. This seems to work.

johngg@abouriou:~/perl/Monks$ perl -E 'say 0.6505 / 0.0001;' 6505

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: finding the correct integer
by YarNik (Sexton) on Nov 30, 2020 at 15:02 UTC
    your code not return integer
    print 0.65051 / 0.0001; 6505.1

      Your code does not duplicate johngg's code.


      Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2023-01-31 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?