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:  <%-{-{-{-<