Mir 1.0
Mir application programming interface
Arithmetic functions

Functions

int mirml_ipow (int base, int exp)
 Integer exponentiation: baseexp. More...
 
mirkl_int64_t mirml_i64pow (mirkl_int64_t base, mirkl_int64_t exp)
 Similar to mirml_ipow but for 64-bit integers.
 
int mirml_test_int64add (mirkl_int64_t si1, mirkl_int64_t si2)
 Tests whether the result of addition of two signed 64-bit integers si1 + si2 fits into a 64-bit signed integer. More...
 
int mirml_test_int64sub (mirkl_int64_t si1, mirkl_int64_t si2)
 Tests whether the result of substraction of two signed 64-bit integers si1 - si2 fits into a 64-bit signed integer. More...
 
int mirml_test_int64mult (mirkl_int64_t si1, mirkl_int64_t si2)
 Tests whether the result of multiplication of two signed 64-bit integers si1 * si2 fits into a 64-bit signed integer. More...
 
int mirml_test_int64rem (mirkl_int64_t si1, mirkl_int64_t si2)
 Tests whether it is possible to calculate remainder of division si1 / si2. More...
 
int mirml_test_int64div (mirkl_int64_t si1, mirkl_int64_t si2)
 Tests whether it is possible to calculate result of division si1 / si2. More...
 
int mirml_test_int64umin (mirkl_int64_t s)
 Tests whether it is possible to apply unary negation operation to s. More...
 
int mirml_is_number (double x)
 Tests the double number if it is NaN or not. More...
 
int mirml_is_finite_number (double x)
 Tests the double number is finite. More...
 
int mirml_cmp_double (double a, double b, double epsilon)
 Comparison of two double numbers. More...
 
int mirml_cmp_float (float a, float b, float epsilon)
 Comparison of two float numbers. More...
 

Detailed Description

Function Documentation

◆ mirml_cmp_double()

int mirml_cmp_double ( double  a,
double  b,
double  epsilon 
)

Comparison of two double numbers.

This functions takes into account magnitude of the numbers and precision.

Parameters
[in]aFirst value to be compared with the second one.
[in]bSecond value.
[in]epsilonPrecision for comparison. This is compared to relative difference. Only if the difference is close to zero or one of the numbers is exactly zero, then this number is used as absolute precision.
Returns
This function returns 0 if numbers are equal, 1 when a > b and -1 when a < b.

◆ mirml_cmp_float()

int mirml_cmp_float ( float  a,
float  b,
float  epsilon 
)

Comparison of two float numbers.

Similar to mirml_cmp_double, see details therein.

◆ mirml_ipow()

int mirml_ipow ( int  base,
int  exp 
)

Integer exponentiation: baseexp.

Parameters
[in]baseMust be positive.
[in]expMust be positive.
Returns
positive result or negative value in case when result does not fit into signed integer.

◆ mirml_is_finite_number()

int mirml_is_finite_number ( double  x)

Tests the double number is finite.

Parameters
[in]xTested value
Returns
1 if the number is finite, 0 otherwise.

◆ mirml_is_number()

int mirml_is_number ( double  x)

Tests the double number if it is NaN or not.

Parameters
[in]xTested value
Returns
1 if number, 0 if NaN.

◆ mirml_test_int64add()

int mirml_test_int64add ( mirkl_int64_t  si1,
mirkl_int64_t  si2 
)

Tests whether the result of addition of two signed 64-bit integers si1 + si2 fits into a 64-bit signed integer.

Parameters
[in]si1First value
[in]si2Second value
Returns
1 if the result fits into 64-bit signed integer, otherwise - 0.

◆ mirml_test_int64div()

int mirml_test_int64div ( mirkl_int64_t  si1,
mirkl_int64_t  si2 
)

Tests whether it is possible to calculate result of division si1 / si2.

Parameters
[in]si1Numerator
[in]si2Denominator
Returns
1 if possible, otherwise - 0.

◆ mirml_test_int64mult()

int mirml_test_int64mult ( mirkl_int64_t  si1,
mirkl_int64_t  si2 
)

Tests whether the result of multiplication of two signed 64-bit integers si1 * si2 fits into a 64-bit signed integer.

Parameters
[in]si1First value
[in]si2Second value
Returns
1 if the result fits into 64-bit signed integer, otherwise - 0.

◆ mirml_test_int64rem()

int mirml_test_int64rem ( mirkl_int64_t  si1,
mirkl_int64_t  si2 
)

Tests whether it is possible to calculate remainder of division si1 / si2.

Parameters
[in]si1Numerator
[in]si2Denominator
Returns
1 if possible, otherwise - 0.

◆ mirml_test_int64sub()

int mirml_test_int64sub ( mirkl_int64_t  si1,
mirkl_int64_t  si2 
)

Tests whether the result of substraction of two signed 64-bit integers si1 - si2 fits into a 64-bit signed integer.

Parameters
[in]si1First value
[in]si2Second value
Returns
1 if the result fits into 64-bit signed integer, otherwise - 0.

◆ mirml_test_int64umin()

int mirml_test_int64umin ( mirkl_int64_t  s)

Tests whether it is possible to apply unary negation operation to s.

Parameters
[in]sTested value
Returns
1 if possible, otherwise - 0.