The functions that implement math operators using at least some C-style integers.
More...
| uintmax_t | BCD_int::abs_bcd_cuint (const BCD_int x) |
| | Attempt to get the C-style absolute value of x. More...
|
| |
| intmax_t | BCD_int::val_bcd_cint (const BCD_int x) |
| | Attempt to get the C-style signed representation of x. More...
|
| |
| comp_t | BCD_int::cmp_bcd_cint (const BCD_int x, const intmax_t y) |
| | compare a BCD_int with a C-style signed integer More...
|
| |
| comp_t | BCD_int::cmp_bcd_cuint (const BCD_int x, const uintmax_t y) |
| | compare a BCD_int with a C-style unsigned integer More...
|
| |
| BCD_int | BCD_int::mul_bcd_cint (const BCD_int x, const intmax_t y) |
| | Multiply a BCD_int by a C-style signed integer. More...
|
| |
| BCD_int | BCD_int::mul_bcd_cuint (const BCD_int x, uintmax_t y) |
| | Multiply a BCD_int by a C-style unsigned integer. More...
|
| |
| BCD_int | BCD_int::mul_bcd_pow_10 (const BCD_int x, const size_t tens) |
| | Multiply a BCD_int by a power of ten. More...
|
| |
| BCD_int | BCD_int::shift_bcd_left (const BCD_int a, const size_t tens) |
| | Multiply a BCD_int by a power of ten. More...
|
| |
| BCD_int | BCD_int::div_bcd_pow_10 (const BCD_int x, const size_t tens) |
| | Divide a BCD_int by a power of ten. More...
|
| |
| BCD_int | BCD_int::shift_bcd_right (const BCD_int a, const size_t tens) |
| | Divide a BCD_int by a power of ten. More...
|
| |
| BCD_int | BCD_int::pow_cint_cuint (const intmax_t x, uintmax_t y) |
| | Raise a C-style integer to the power of another C-style signed integer. More...
|
| |
| BCD_int | BCD_int::pow_cuint_cuint (const uintmax_t x, uintmax_t y) |
| | Raise a C-style integer to the power of another C-style unsigned integer. More...
|
| |
The functions that implement math operators using at least some C-style integers.
c_operators
| uintmax_t abs_bcd_cuint |
( |
const BCD_int |
x | ) |
|
Attempt to get the C-style absolute value of x.
- Parameters
-
- Returns
- Either the value of x OR -1 if x is NaN or |x| would overflow
| comp_t cmp_bcd_cint |
( |
const BCD_int |
x, |
|
|
const intmax_t |
y |
|
) |
| |
compare a BCD_int with a C-style signed integer
- Parameters
-
| [in] | x | The BCD_int in question |
| [in] | y | The signed integer you would like to compare with |
- Returns
- A comp_t indicating the difference between x and y
- Note
- Returns NO_COMP if x is NaN
- See also
- cmp_bcd
| comp_t cmp_bcd_cuint |
( |
const BCD_int |
x, |
|
|
const uintmax_t |
y |
|
) |
| |
compare a BCD_int with a C-style unsigned integer
- Parameters
-
| [in] | x | The BCD_int in question |
| [in] | y | The signed integer you would like to compare with |
- Returns
- A comp_t indicating the difference between x and y
- Note
- Returns NO_COMP if x is NaN
- See also
- cmp_bcd
Divide a BCD_int by a power of ten.
- Parameters
-
| [in] | x | The BCD_int you'd like to divide |
| [in] | tens | The power of ten to divide by (in the form of \((10^{\texttt{tens}})\)) |
- Returns
- The result of \((x \div 10^{\texttt{tens}})\)
- Warning
- This function does not do true division, it simply trims digits. If you need true division, use div_bcd
-
As implemented, this function is equivalent to
{int(str(x)[:-y])}. If you assume this is true division, you will get frequent off-by-one errors.
- 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.
Multiply a BCD_int by a C-style signed integer.
- Parameters
-
| [in] | x | The BCD_int in question |
| [in] | y | The C-style integer to multiply by |
- Returns
- The product of x and y
- 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.
Multiply a BCD_int by a C-style unsigned integer.
- Parameters
-
| [in] | x | The BCD_int in question |
| [in] | y | The C-style integer to multiply by |
- Returns
- The product of x and y
- 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.
Multiply a BCD_int by a power of ten.
- Parameters
-
| [in] | x | The BCD_int you'd like to multiply |
| [in] | tens | The power of ten to multiply by (in the form of \((10^{\texttt{tens}})\)) |
- Returns
- The result of \((x \cdot 10^{\texttt{tens}})\)
- 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.
| BCD_int pow_cint_cuint |
( |
const intmax_t |
x, |
|
|
uintmax_t |
y |
|
) |
| |
Raise a C-style integer to the power of another C-style signed integer.
- Parameters
-
| [in] | x | The base |
| [in] | y | The exponent |
- Returns
- The yth power of x in the form of a BCD_int
- 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.
| BCD_int pow_cuint_cuint |
( |
const uintmax_t |
x, |
|
|
uintmax_t |
y |
|
) |
| |
Raise a C-style integer to the power of another C-style unsigned integer.
- Parameters
-
| [in] | x | The base |
| [in] | y | The exponent |
- Returns
- The yth power of x in the form of a BCD_int
- 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.
Multiply a BCD_int by a power of ten.
- Parameters
-
| [in] | a | The BCD_int you'd like to multiply |
| [in] | tens | The power of ten to multiply by (in the form of \((10^{\texttt{tens}})\)) |
- Returns
- The result of \((x \cdot 10^{\texttt{tens}})\)
- 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.
- Note
- This is just an alias for mul_bcd_pow_10
Divide a BCD_int by a power of ten.
- Parameters
-
| [in] | a | The BCD_int you'd like to divide |
| [in] | tens | The power of ten to divide by (in the form of \((10^{\texttt{tens}})\)) |
- Returns
- The result of \((x \div 10^{\texttt{tens}})\)
- Warning
- This function does not do true division, it simply trims digits. If you need true division, use div_bcd
-
As implemented, this function is equivalent to
{int(str(x)[:-y])}. If you assume this is true division, you will get frequent off-by-one errors.
- 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.
- Note
- This is just an alias for div_bcd_pow_10
| intmax_t val_bcd_cint |
( |
const BCD_int |
x | ) |
|
Attempt to get the C-style signed representation of x.
- Parameters
-
- Returns
- Either the value of x OR INTMAX_MIN if x is NaN or |x| would overflow