# Math
# Description
The Math namespace contains tools for mathematical calculations, especially functionality related to floating-point precision handling.
# How to Use
// Using functions from the Math namespace
bool isZero = Math::IsZero(0.00000001f);
bool areEqual = Math::NearEqual(0.1f + 0.2f, 0.3f);
// Using Float_t type from Math namespace
Math::Float_t floatVal(3.14159f);
# Constants
# M_PI
#define M_PI 3.14159265358979323846f
Represents the value of pi (π).
float halfCircleRadians = M_PI; // Radian value of 180 degrees
# IsZero
bool IsZero(float A)
Checks if a floating-point number is zero (considering floating-point precision issues).
Parameter | Type | Description |
---|---|---|
A | float | The floating-point number to check |
float value = 0.00000001f;
bool isZero = Math::IsZero(value);
# NearEqual
bool NearEqual(float A, float B, int maxUlpsDiff = 4)
Checks if two floating-point numbers are approximately equal, considering floating-point precision issues.
Parameter | Type | Description |
---|---|---|
A | float | First floating-point number |
B | float | Second floating-point number |
maxUlpsDiff | int | Maximum Units in Last Place difference, default is 4 |
float value1 = 0.1f + 0.2f;
float value2 = 0.3f;
bool areEqual = Math::NearEqual(value1, value2);
# Class:Float_t
A floating-point handling class that provides access to and manipulation of the internal components of floating-point numbers.
Math::Float_t floatVal(3.14159f);
# Float_t.Negative
bool Negative() const
Determines if the floating-point number is negative.
Math::Float_t floatVal(-3.14f);
bool isNegative = floatVal.Negative(); // Returns true
# Float_t.RawMantissa
int32_t RawMantissa() const
Gets the raw mantissa bits of the floating-point number.
Math::Float_t floatVal(3.14f);
int32_t mantissa = floatVal.RawMantissa();
# Float_t.RawExponent
int32_t RawExponent() const
Gets the raw exponent bits of the floating-point number.
Math::Float_t floatVal(3.14f);
int32_t exponent = floatVal.RawExponent();