Přeskočit na hlavní obsah

//ERDDAP/com.cohort.util/ScriptMath2/almostEqual

almostEqual

[JVM]
open fun almostEqual(nSignificantDigits: Int, d1: Double, d2: Double): Boolean

This tests if the numbers are equal to at least n significant digits.

  • Numbers must match to 1 part in 10^n to ensure that rounding to n-1 digits is identical.
  • If d1 and d2 are almost0, this returns true.
  • This is slow compared to almost0.

Return

true if the numbers are equal to at least n significant digits (or are both almost0). If either number is NaN or Infinity, this returns false.

Parameters

JVM

nSignificantDigits0 to 18 are allowed; 5, 9, and 14 are common
d1any double
d2any double

[JVM]
open fun almostEqual(nSignificantDigits: Int, f1: Float, f2: Float): Boolean

This tests if two floats are equal to at least n significant digits.

Return

true if the numbers are equal to at least n significant digits (or are both almost0). If either number is NaN or Infinity, this returns false.

Parameters

JVM

nSignificantDigits0 to 18 are allowed; 5, 9, and 14 are common
f1any float
f2any float