http://www.perlmonks.org?node_id=790872


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?