This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: PR29335 use MPFR for builtins fma, fmin and fmax



'If just one argument is NaN, the fmax functions return the other
argument (if both
arguments are NaNs, the functions return NaN).

The body of the fmax function might be
  { return (isgreater (x, y) || isnan(y)) ? x : y; }
"

but I agree that the one-argument NaN thing is stupid and not what would be
usually expected.

Yeah, NaN propagation would be the expected behavior in that case! And Java got it right, actually: grep for min(float or max(float in libjava/java/lang/Math.java.


In a footnote it says

"Ideally, fmax would be sensitive to the sign of zero, for example
fmax (-0.0, 0.0)
would return 0; however, implementation in software might be impractical."

<ironic>
They mean, as impractical as "a == b ? a & b : (a > b ? a : b)" (I really mean & as bitwise AND)? Or likewise, "a == b ? a | b : (a < b ? a : b)" for fmin?
</ironic>


Java BTW also got this right, though they have no &/| on float and they resort to a special case for a == 0 && b == 0.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]