fixed_math

Addition in FixedMath

The FixedMath library meticulously handles the addition of fixed-point numbers (fixed_t), ensuring precision and correctness across various operations. This includes support for mixed-type arithmetic involving fixed_t, integers, and floating-point numbers.

Core Addition Functionality

Type Promotion and Arithmetic

Addition Operator Overloads

Specialized Addition Functions

Safety and Precision

The FixedMath addition operations are designed with an emphasis on safety, ensuring that any potential overflow or underflow conditions are handled gracefully, returning NaN where appropriate.

Usage Example

fixed_t a = ...; // Initialize with some value
fixed_t b = ...; // Another fixed_t value
fixed_t result = a + b; // Addition of two fixed_t values

int scalar = 5;
fixed_t result2 = a + scalar; // Addition with an integer scalar

double d = 2.0;
auto result3 = a + d; // Addition with a double, result is promoted to double