Project Euler Solutions
Bcd_utility

A couple of utility functions for BCD_int. More...

uint16_t c::include::bcd::mul_dig_pair (const packed_BCD_pair ab, const packed_BCD_pair cd)
 Multiply a pair of BCD bytes. More...
 
void BCD_int::print_bcd (const BCD_int x)
 Print a BCD_int to the screen. More...
 
void BCD_int::print_bcd_ln (const BCD_int x)
 Print a BCD_int to the screen and append a newline. More...
 

Detailed Description

A couple of utility functions for BCD_int.

utility

Function Documentation

uint16_t c::include::bcd::mul_dig_pair ( const packed_BCD_pair  ab,
const packed_BCD_pair  cd 
)
inline

Multiply a pair of BCD bytes.

Parameters
[in]abThe first byte, which gets split into nibbles a and b
[in]cdThe second byte, which gets split into nibbles c and d
Remarks
This function runs takes \(Θ(1)\) time
Returns
\(100 \cdot a \cdot c + 10 \cdot (a \cdot d + b \cdot c) + b \cdot d\)

Here is the caller graph for this function:

void print_bcd ( const BCD_int  x)

Print a BCD_int to the screen.

Parameters
[in]xThe BCD_int you'd like to print
Remarks
This function runs takes \(Θ(\log_{100}(x))\) time

Here is the caller graph for this function:

void print_bcd_ln ( const BCD_int  x)

Print a BCD_int to the screen and append a newline.

Parameters
[in]xThe BCD_int you'd like to print
Remarks
This function runs takes \(Θ(\log_{100}(x))\) time