include/Cnx/Math.h file

This module extends <tgmath.h> and provides some alternative math functions.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Functions

i64 cnx_gcd_i64(i64 left, i64 right)
Calculate the gcd of the two inputs.
u64 cnx_gcd_u64(u64 left, u64 right)
Calculate the gcd of the two inputs.
i64 cnx_lcm_i64(i64 left, i64 right)
Calculate the lcm of the two inputs.
u64 cnx_lcm_u64(u64 left, u64 right)
Calculate the lcm of the two inputs.
CnxOption(u8) cnx_checked_add_u8(u8 left
Performs the checked addition of left and right
CnxOption(u16) cnx_checked_add_u16(u16 left
Performs the checked addition of left and right
CnxOption(u32) cnx_checked_add_u32(u32 left
Performs the checked addition of left and right
CnxOption(u64) cnx_checked_add_u64(u64 left
Performs the checked addition of left and right
CnxOption(i8) cnx_checked_add_i8(i8 left
Performs the checked addition of left and right
CnxOption(i16) cnx_checked_add_i16(i16 left
Performs the checked addition of left and right
CnxOption(i32) cnx_checked_add_i32(i32 left
Performs the checked addition of left and right
CnxOption(i64) cnx_checked_add_i64(i64 left
Performs the checked addition of left and right
CnxOption(f32) cnx_checked_add_f32(f32 left
Performs the checked addition of left and right
CnxOption(f64) cnx_checked_add_f64(f64 left
Performs the checked addition of left and right

Defines

#define CNX_MATH
Declarations and definitions related to Cnx math functions.
#define cnx_min(x, y)
Returns the minimum of the two arguments.
#define min(x, y)
Returns the minimum of the two arguments.
#define cnx_max(x, y)
Returns the maximum of the two arguments.
#define max(x, y)
Returns the maximum of the two arguments.
#define cnx_abs(x)
Returns the absolute value of the given one.
#define abs(x)
Returns the absolute value of the given one.
#define cnx_static_abs(x)
Calculates the absolute value of the given input at compile time.
#define cnx_static_sign(x)
Calculates the sign of the given input at compile time.
#define cnx_sign(x)
Calculates the sign of the given input.
#define cnx_gcd(left, right)
Calculate the gcd of the two inputs.
#define cnx_static_gcd(left, right)
Calculate the gcd of the two inputs at compile time.
#define cnx_lcm(left, right)
Calculate the lcm of the two inputs.
#define cnx_static_lcm(left, right)
Calculate the lcm of the two inputs at compile time.
#define cnx_static_checked_add(left, right)
Performs the checked addition of left and right at compile-time.
#define cnx_checked_sub(left, right)
Performs the checked subtraction of right from left
#define cnx_static_checked_sub(left, right)
Performs the checked subtraction of right from left at compile-time.
#define cnx_checked_mul(left, right)
Performs the checked multiplication of left and right
#define cnx_static_checked_mul(left, right)
Performs the checked multiplication of left and right at compile-time.
#define cnx_checked_div(left, right)
Performs the checked division of left and right
#define cnx_static_checked_div(left, right)
Performs the checked division of left and right at compile-time.