Project Euler Solutions
The functions that implement in-place math operators using only BCD_int objects
void BCD_int::isign_bcd (BCD_int *const x, const bool negative)
 Change the sign of a BCD_int without relying on internals. More...
 
void BCD_int::iabs_bcd (BCD_int *const x)
 Get the absolute value of a BCD_int without relying on internals. More...
 
void BCD_int::ineg_bcd (BCD_int *const x)
 Get the negative absolute value of a BCD_int without relying on internals. More...
 
void BCD_int::iopp_bcd (BCD_int *const x)
 Get the opposite value of a BCD_int without relying on internals. More...
 
void BCD_int::iadd_bcd (BCD_int *const x, const BCD_int y)
 Add two BCD_ints and assign the result to x. More...
 
void BCD_int::iinc_bcd (BCD_int *const x)
 Increment a BCD_int and assign the result to x. More...
 
void BCD_int::isub_bcd (BCD_int *const x, const BCD_int y)
 Subtract two BCD_ints and assign the result to x. More...
 
void BCD_int::idec_bcd (BCD_int *const x)
 Decrement a BCD_int and assign the result to x. More...
 
void BCD_int::imul_bcd (BCD_int *const x, const BCD_int y)
 Multiply two BCD_ints and assign the result to x. More...
 
void BCD_int::idiv_bcd (BCD_int *const x, const BCD_int y)
 Divide two BCD_ints and assign the result to x. More...
 
void BCD_int::imod_bcd (BCD_int *const x, const BCD_int y)
 Modulo divide two BCD_ints and assign the result to x. More...
 
void BCD_int::idivmod_bcd (BCD_int *const x, BCD_int *const y)
 Divide two BCD_ints then assign the quotient to x and remainder to y. More...
 
void BCD_int::ipow_bcd (BCD_int *const x, const BCD_int y)
 Raise x to the power of y then assign the result to x. More...
 
void BCD_int::ifactorial_bcd (BCD_int *const x)
 Get the factorial of x then assign the result to x. More...
 

Detailed Description

in_place_operators

Function Documentation

void iabs_bcd ( BCD_int *const  x)

Get the absolute value of a BCD_int without relying on internals.

Parameters
[in,out]xThe BCD_int in question
Remarks
This function runs takes \(Θ(1)\) time
Attention
All in-place operators may "return" NaN with error set to NO_MEM (for sign modifiers this is only possible if x is a constant)
All in-place operators will "return" NaN if fed NaN, and on sign modifiers error is left untouched
void iadd_bcd ( BCD_int *const  x,
const BCD_int  y 
)

Add two BCD_ints and assign the result to x.

Parameters
[in,out]xThe left-hand BCD_int
[in]yThe right-hand BCD_int
See also
add_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.
void idec_bcd ( BCD_int *const  x)

Decrement a BCD_int and assign the result to x.

Parameters
[in,out]xThe left-hand BCD_int
See also
dec_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.
void idiv_bcd ( BCD_int *const  x,
const BCD_int  y 
)

Divide two BCD_ints and assign the result to x.

Parameters
[in,out]xThe left-hand BCD_int
[in]yThe right-hand BCD_int
See also
div_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.
"Returns" NaN with error set to DIV_ZERO if y is 0
void idivmod_bcd ( BCD_int *const  x,
BCD_int *const  y 
)

Divide two BCD_ints then assign the quotient to x and remainder to y.

Parameters
[in,out]xThe left-hand BCD_int
[in,out]yThe right-hand BCD_int
See also
divmod_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.
"Returns" two BCD_nans with error set to DIV_ZERO if y is 0
void ifactorial_bcd ( BCD_int *const  x)

Get the factorial of x then assign the result to x.

Parameters
[in,out]xThe BCD_int in question
See also
factorial_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.
"Returns" NaN with error set to FACT_NEG if x < 0

Here is the caller graph for this function:

void iinc_bcd ( BCD_int *const  x)

Increment a BCD_int and assign the result to x.

Parameters
[in,out]xThe left-hand BCD_int
See also
inc_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.
void imod_bcd ( BCD_int *const  x,
const BCD_int  y 
)

Modulo divide two BCD_ints and assign the result to x.

Parameters
[in,out]xThe left-hand BCD_int
[in]yThe right-hand BCD_int
See also
mod_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.
"Returns" NaN with error set to DIV_ZERO if y is 0
void imul_bcd ( BCD_int *const  x,
const BCD_int  y 
)

Multiply two BCD_ints and assign the result to x.

Parameters
[in,out]xThe left-hand BCD_int
[in]yThe right-hand BCD_int
See also
mul_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.
void ineg_bcd ( BCD_int *const  x)

Get the negative absolute value of a BCD_int without relying on internals.

Parameters
[in,out]xThe BCD_int in question
Remarks
This function runs takes \(Θ(1)\) time
Attention
All in-place operators may "return" NaN with error set to NO_MEM (for sign modifiers this is only possible if x is a constant)
All in-place operators will "return" NaN if fed NaN, and on sign modifiers error is left untouched
void iopp_bcd ( BCD_int *const  x)

Get the opposite value of a BCD_int without relying on internals.

Parameters
[in,out]xThe BCD_int in question
Remarks
This function runs takes \(Θ(1)\) time
Attention
All in-place operators may "return" NaN with error set to NO_MEM (for sign modifiers this is only possible if x is a constant)
All in-place operators will "return" NaN if fed NaN, and on sign modifiers error is left untouched
void ipow_bcd ( BCD_int *const  x,
const BCD_int  y 
)

Raise x to the power of y then assign the result to x.

Parameters
[in,out]xThe left-hand BCD_int
[in]yThe right-hand BCD_int
See also
pow_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.
"Returns" NaN with error set to POW_NEG if y < 0
void isign_bcd ( BCD_int *const  x,
const bool  negative 
)

Change the sign of a BCD_int without relying on internals.

Parameters
[in,out]xThe BCD_int in question
[in]negativeThe sign you would like to apply
Remarks
This function runs takes \(Θ(1)\) time
Attention
All in-place operators may "return" NaN with error set to NO_MEM (for sign modifiers this is only possible if x is a constant)
All in-place operators will "return" NaN if fed NaN, and on sign modifiers error is left untouched
void isub_bcd ( BCD_int *const  x,
const BCD_int  y 
)

Subtract two BCD_ints and assign the result to x.

Parameters
[in,out]xThe left-hand BCD_int
[in]yThe right-hand BCD_int
See also
sub_bcd for performance analysis
Attention
All in-place operators may "return" NaN with error set to NO_MEM
All in-place operators will "return" NaN if fed NaN, and set error to {OP}_NAN.