Class Num
Provides commonly used numeric constants and utility methods for floating-point comparisons throughout the Scylla framework.
Inherited Members
Namespace: Scylla.Core
Assembly: ScyllaCore.dll
Syntax
public static class Num
Remarks
For more comprehensive math utilities and floating-point comparison methods, see
NumberUtil (which provides Approximately and other numeric helpers)
and MathUtil.
Fields
FLOAT_TOLERANCE
Default tolerance value for floating-point equality comparisons. Two floats whose
absolute difference is less than this value (0.001) are considered equal by
IsEqual(float, float, float). This tolerance is suitable for most gameplay and UI calculations
but may be too coarse for high-precision math (use a smaller tolerance in those cases).
Declaration
public const float FLOAT_TOLERANCE = 0.001
Field Value
| Type | Description |
|---|---|
| float |
Methods
IsEqual(float, float, float)
Compares two floating-point values for approximate equality using an absolute tolerance.
Returns true if the absolute difference between the two values is strictly less
than the specified tolerance.
Declaration
public static bool IsEqual(float num1, float num2, float tolerance = 0.001)
Parameters
| Type | Name | Description |
|---|---|---|
| float | num1 | The first floating-point value to compare. |
| float | num2 | The second floating-point value to compare. |
| float | tolerance | The maximum allowed absolute difference between |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
This method uses an absolute (not relative) tolerance comparison, which works well
for values near zero but may need a tighter or wider tolerance for very large or
very small magnitudes. For a relative-error comparison, consider using
NumberUtil.Approximately.