Rational(0, 1) ** -1.0
=> +Infinity on most platforms, -Infinity on Solaris by default.
The Rational is implicitly converted to the Float value 0.0, and the libm function pow(0.0, -1.0) is called.
Should this kind of behavior be made consistent by Ruby or should we accept this as dependent on the libm/libc used?
They are likely other edges cases for pow() which might differ, and I think in general
Ruby should try to unify these cases so the behavior is consistent across platforms at least for arithmetic.
Yes, with default compiler option.
On Solaris, the 0.0 ** -1 could return 3 different values depending on compile-time options: 0, -Infinity, +Infinity.
This is an inconsistency in the default behavior of the Solaris pow function compared to other platforms. You could file this as a bug in the Illumios bug tracker (or raise an issue with Oracle Solaris support) if you would like them to change the behavior: https://www.illumos.org/projects/illumos-gate/issues
In the C99 spec, The behavior of pow(3) in corner cases are clearly defined.
Since Ruby 2.7, C99 is required to compile CRuby source code, and thus Ruby's pow method conforms to the C99 standard.