Skip to content
API referenceDevelopmentEngine APIEngine ccf7d03f
Synced
  • Determines whether two floating-point numbers are approximately equal, using a relative tolerance based on the magnitude of the numbers. This is useful for comparing floats where rounding errors may occur.

API: engine
Project: Inno.Core.Mathematics

public static bool Inno.Core.Mathematics.MathHelper.AlmostEquals(float a, float b, float relTolerance = 1E-06)

Parameter a: The first float value to compare.

Parameter b: The second float value to compare.

Parameter relTolerance: The relative tolerance allowed between a and b. Default is 1e-6. The comparison checks if the difference is within relTolerance * max(|a|, |b|).

true if the absolute difference between a and b is less than or equal to the relative tolerance multiplied by the larger magnitude of the two values; otherwise, false.