Gå til hovedindholdet

//ERDDAP/com.cohort.util/ScriptString2/toRational

toRational

[JVM]
open fun toRational(d: Double): Array<Int>

This converts a double to a rational number (m * 10^t). This is similar to Math2.mantissa and Math2.intExponent, but works via string manipulation to avoid roundoff problems (e.g., with 6.6260755e-24).

Return

int[2]: [0]=m, [1]=t. (or {0, 0} if d=0, or {1, Integer.MAX_VALUE} if !finite(d))

Parameters

JVM

d