unaryMinus

operator fun unaryMinus(): Rational

Negation, widened before it negates.

-Int.MIN_VALUE is Int.MIN_VALUE again in 32-bit arithmetic, so negating a rational whose numerator sat at the floor used to return the SAME rational and call it the opposite sign (audit P1-29). Widening first makes that case a value that does not fit, which of refuses out loud rather than answering wrongly.

Throws

when the negated numerator does not fit 32 bits