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

Re^2: int($x) gives strange result

by ikegami (Pope)
on Aug 24, 2009 at 17:35 UTC ( #790872=note: print w/replies, xml ) Need Help??

in reply to Re: int($x) gives strange result
in thread int($x) gives strange result

That's misleading. floor and ceil suffer the same problem as int in this area.
$ perl -MPOSIX -wle'$x = 6.725/0.025; print for $x, int $x, floor $x' 269 268 268

Replies are listed 'Best First'.
Re^3: int($x) gives strange result
by hossman (Prior) on Aug 31, 2009 at 05:53 UTC

    It's not really fair to argue that a post is misleading when the post just quotes the function documentation in it's entirety, and emphasizes (bolded) the part of the documentation that is relevant to the discussion. That doesn't imply the rest of the documentation is on point -- if anything it suggests that the rest of the documentation is not on point, otherwise all/none of it would have been emphasized.

      The OP didn't give any indication that he didn't want to truncate towards zero, so the bolded passage didn't apply, so it never occurred to me that the Anonymous Monk altered the quote to add his own emphasis.

      In fact, it had not even occurred to me until you mentioned it. I took it at face value when he said it was from perldoc.

      In any case, I immediately clarified myself when confusion arose.

Re^3: int($x) gives strange result
by Anonymous Monk on Aug 25, 2009 at 00:29 UTC
      I never said it was. In response to the post, I said it was misleading. I didn't say anything about that line specifically. In fact, I went on to show what was misleading, and it had nothing to do with that line. The "POSIX::floor" and "POSIX::ceil" functions will not serve you better than will int().
        How is it misleading, it explains how int truncates works?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2020-07-07 05:39 GMT
Find Nodes?
    Voting Booth?

    No recent polls found