in reply to Re^8: Weird behavior of int()
in thread Weird behavior of int()

We're talking about the C's trunc, so the C spec. (I specifically quoted C18, but I bet it's the exact same words since 89.)

Replies are listed 'Best First'.
Re^10: Weird behavior of int()
by pryrt (Abbot) on May 22, 2024 at 17:10 UTC
    Thank you for clarifying.

    However, whether or not all trunc implementations do it that way, it doesn't change my main points: preserving INF and NAN through an operation like perl's int is reasonable.

    I was using the example of POSIX-compliant trunc , not because I was saying "since trunc requires this behavior (which you have pointed out is not true), then perl's int must behave this way", but because I was saying "since something like POSIX's implementation of trunc implements it this way, I believe it is reasonable to implement such functions this way, whether it's an implementation of trunc or of perl's func or any other similar "return the integer portion of a number that might have a non-integer component" function.