FloatExtensions

Static Class in Zigurous.Math

Declaration

public static class FloatExtensions

Description

Extension methods for floats.

Properties

SAFE_FLOATSometimes Unity throws precision errors for really small numbers such as when setting transform values. Using float.Epsilon can still cause issues so this value is intended to be a safer alternative.

Extension Methods

IsNaNChecks if the value is NaN.
IsInfiniteChecks if the value is infinite.
IsPositiveInfinityChecks if the value is equal to positive infinity.
IsNegativeInfinityChecks if the value is equal to negative infinity.
IsRealNumberChecks if the value is a real number (not infinite and not NaN).
IsImaginaryNumberChecks if the value is an imaginary number (infinite or NaN).
IsDividableChecks if the value can be divided (not zero, not infinite, and not NaN).
IsPositiveChecks if the value is positive.
IsNegativeChecks if the value is negative.
IsZeroChecks if the value is zero given a margin of error specified by an epsilon.
IsEqualToChecks for equality with another value given a margin of error specified by an epsilon.
ToAbbreviatedStringConverts the number to an abbreviated string, e.g. "1k" for 1000.
UnsetImaginarySets the value to a new value if the value is an imaginary number (infinite or NaN).
UnsetInfiniteSets the value to a new value if the value is an infinite number.
UnsetNaNSets the value to a new value if the value is NaN.
UnsetZeroSets the value to a new value if the value is zero given a margin of error specified by an epsilon.