scalb

fun scalb(d: Double, scaleFactorInput: Int): Double

Multiplies this by 2^scaleFactor with the same edge-case semantics as Math.scalb (IEEE 754 scaleB operation). The implementation is a direct Kotlin port of the JDK algorithm. It guarantees:

  • exact results for all intermediate exponents in MIN_EXPONENT, MAX_EXPONENT;

  • correct overflow to ±∞ and propagation of NaN / 0 signs;

  • only one rounding step when scaling down, mirroring the JDK’s ordering constraints that avoid cascaded sub-normal rounding.