The functions that implement math operators using only BCD_int objects.
More...
| comp_t | BCD_int::cmp_bcd (const BCD_int x, const BCD_int y) |
| | Compare two BCD_ints. More...
|
| |
| BCD_int | BCD_int::sign_bcd (BCD_int x, const bool no_copy, const bool negative) |
| | Change the sign of a BCD_int without relying on internals. More...
|
| |
| BCD_int | BCD_int::abs_bcd (const BCD_int x, const bool no_copy) |
| | Get the absolute value of a BCD_int without relying on internals. More...
|
| |
| BCD_int | BCD_int::neg_bcd (const BCD_int x, const bool no_copy) |
| | Get the negative absolute value of a BCD_int without relying on internals. More...
|
| |
| BCD_int | BCD_int::opp_bcd (const BCD_int x, const bool no_copy) |
| | Get the opposite value of a BCD_int without relying on internals. More...
|
| |
| BCD_int | BCD_int::add_bcd (const BCD_int x, const BCD_int y) |
| | Add two BCD_ints. More...
|
| |
| BCD_int | BCD_int::inc_bcd (const BCD_int x) |
| | Increment a BCD_int. More...
|
| |
| BCD_int | BCD_int::sub_bcd (const BCD_int x, const BCD_int y) |
| | Subtract two BCD_ints. More...
|
| |
| BCD_int | BCD_int::dec_bcd (const BCD_int x) |
| | Decrement a BCD_int. More...
|
| |
| BCD_int | BCD_int::mul_bcd (const BCD_int x, const BCD_int y) |
| | Multiply two BCD_ints. More...
|
| |
| BCD_int | BCD_int::div_bcd (const BCD_int x, const BCD_int y) |
| | Divide two BCD_ints. More...
|
| |
| BCD_int | BCD_int::mod_bcd (const BCD_int x, const BCD_int y) |
| | Modulo divide two BCD_ints. More...
|
| |
| BCD_int | BCD_int::divmod_bcd (const BCD_int x, BCD_int y, BCD_int *mod) |
| | Divide and modulo divide two BCD_ints. More...
|
| |
| BCD_int | BCD_int::pow_bcd (const BCD_int x, const BCD_int y) |
| | Raise x to the power of y. More...
|
| |
| BCD_int | BCD_int::factorial_bcd (const BCD_int x) |
| | Get the factorial of x. More...
|
| |
The functions that implement math operators using only BCD_int objects.
operators
Get the absolute value of a BCD_int without relying on internals.
- Parameters
-
| [in] | x | The BCD_int in question |
| [in] | no_copy | If false, this function returns a modified copy of x instead of a modified version of x |
- Returns
- Either a positive copy of x or a positive version of x
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM (avoid with no_copy)
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
- See also
- sign_bcd
Add two BCD_ints.
- Parameters
-
- Returns
- A BCD_int reflecting the sum of the arguments
- Note
- Implementation details:
-
This function works closely with sub_bcd. If absolute value would go down from this operation, it is handed off to that method.
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
Compare two BCD_ints.
- Parameters
-
- Returns
- An comp_t reflecting the comparison
- Return values
-
Decrement a BCD_int.
- Parameters
-
- Returns
- A BCD_int one less than x
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
- See also
- sub_bcd
Divide two BCD_ints.
- Parameters
-
- Returns
- A BCD_int reflecting the quotient of the arguments
- See also
- divmod_bcd for a performance analysis
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
-
Returns NaN with error set to DIV_ZERO if y is 0
Divide and modulo divide two BCD_ints.
- Parameters
-
| [in] | x | The left-hand BCD_int |
| [in] | y | The right-hand BCD_int |
| [out] | mod | A pointer to the BCD_int you would like to store the remainder |
- Returns
- A BCD_int reflecting the quotient of the arguments
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
-
Returns (and assigns to mod) NaN with error set to DIV_ZERO if y is 0
Get the factorial of x.
- Parameters
-
- Returns
- A BCD_int reflecting the factorial of x
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
-
Returns NaN with error set to FACT_NEG if x < 0
Increment a BCD_int.
- Parameters
-
- Returns
- A BCD_int one greater than x
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
- See also
- add_bcd
Modulo divide two BCD_ints.
- Parameters
-
- Returns
- A BCD_int reflecting the remainder of the arguments
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
-
Returns NaN with error set to DIV_ZERO if y is 0
Multiply two BCD_ints.
- Parameters
-
- Returns
- A BCD_int reflecting the product of the arguments
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
Get the negative absolute value of a BCD_int without relying on internals.
- Parameters
-
| [in] | x | The BCD_int in question |
| [in] | no_copy | If false, this function returns a modified copy of x instead of a modified version of x |
- Returns
- Either a negative copy of x or a negative version of x
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM (avoid with no_copy)
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
- See also
- sign_bcd
Get the opposite value of a BCD_int without relying on internals.
- Parameters
-
| [in] | x | The BCD_int in question |
| [in] | no_copy | If false, this function returns a modified copy of x instead of a modified version of x |
- Returns
- Either an opposite copy of x or an opposite version of x
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM (avoid with no_copy)
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
- See also
- sign_bcd
Raise x to the power of y.
- Parameters
-
- Returns
- A BCD_int reflecting the yth power of x
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
-
Returns NaN with error set to POW_NEG if y < 0 or x = 0
| BCD_int sign_bcd |
( |
BCD_int |
x, |
|
|
const bool |
no_copy, |
|
|
const bool |
negative |
|
) |
| |
Change the sign of a BCD_int without relying on internals.
- Parameters
-
| [in] | x | The BCD_int in question |
| [in] | no_copy | If false, this function returns a modified copy of x instead of a modified version of x |
| [in] | negative | The sign you would like to apply |
- Returns
- Either a modified copy of x or a modified version of x
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM (avoid with no_copy)
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.
Subtract two BCD_ints.
- Parameters
-
- Returns
- A BCD_int reflecting the difference of the arguments
- Note
- Implementation details:
-
This function works closely with add_bcd. If absolute value would go up from this operation, it is handed off to that method.
- Attention
- All operators that return a BCD_int may return NaN with error set to NO_MEM
-
All operators that return a BCD_int will return NaN if fed NaN, and set error to {OP}_NAN.