Project Euler Solutions
Bcd_constructors

The functions used to make new BCD_ints. More...

BCD_int BCD_int::new_BCD_int1 (const intmax_t a)
 
BCD_int BCD_int::new_BCD_int2 (uintmax_t a, const bool negative)
 
BCD_int BCD_int::copy_BCD_int (BCD_int a)
 
BCD_int BCD_int::BCD_from_bytes (const unsigned char *const str, const size_t chars, const bool negative, const bool little_endian)
 
BCD_int BCD_int::BCD_from_ascii (const char *const str, const size_t digits, const bool negative)
 
BCD_int BCD_int::bcd_error (const BCD_error error, const BCD_error orig_error)
 A shorthand way of making a BCD_int error object. More...
 

Detailed Description

The functions used to make new BCD_ints.

constructor

Function Documentation

BCD_int bcd_error ( const BCD_error  error,
const BCD_error  orig_error 
)

A shorthand way of making a BCD_int error object.

Parameters
[in]errorThe operation which generated the current error
[in]orig_errorThe operation which initially started generating errors
Returns
A NaN value which has the associated error codes
Remarks
This will take \(Θ(1)\) time
Attention
All constructors may return NaN with error set to NO_MEM
BCD_int BCD_from_ascii ( const char *const  str,
const size_t  digits,
const bool  negative 
)
Parameters
[in]strThe ASCII string you would like to make an integer from, must be decimal numbers (0x30 - 0x39)
[in]digitsThe number of digits
[in]negativeThe sign you would like to apply to the resulting BCD_int
Returns
A BCD_int representation of the given data
Remarks
This will take \(Θ(\texttt{digits})\) time
Attention
All constructors may return NaN with error set to NO_MEM
BCD_int BCD_from_bytes ( const unsigned char *const  str,
const size_t  chars,
const bool  negative,
const bool  little_endian 
)
Parameters
[in]strThe BCD bytes you would like to copy from
[in]charsThe number of bytes
[in]negativeThe sign you would like to apply to the resulting BCD_int
[in]little_endianThe byte order of the fed data (little endian is preferred)
Returns
A BCD_int representation of the given data
Remarks
This will take \(Θ(\texttt{chars})\) time, though it should be noted that little endian data will run significantly faster
Attention
All constructors may return NaN with error set to NO_MEM
BCD_int copy_BCD_int ( BCD_int  a)
Parameters
[in]aThe BCD_int you would like to copy
Returns
A copy of a
Attention
All constructors may return NaN with error set to NO_MEM
Remarks
This will take \(Θ(\log_{100}(a))\) time
BCD_int new_BCD_int1 ( const intmax_t  a)
Parameters
[in]aThe C integer you would like to convert to a BCD_int
Returns
The BCD_int representation of a
Attention
All constructors may return NaN with error set to NO_MEM
Remarks
This will take \(Θ(\log_{100}(a))\) time, but for most purposes you can treat it as \(O(1)\)

Here is the caller graph for this function:

BCD_int new_BCD_int2 ( uintmax_t  a,
const bool  negative 
)
Parameters
[in]aThe C integer you would like to convert to a BCD_int
[in]negativeThe sign of the C integer
Returns
The BCD_int representation of a
Attention
All constructors may return NaN with error set to NO_MEM
Remarks
This will take \(Θ(\log_{100}(a))\) time, but for most purposes you can treat it as \(O(1)\)

Here is the caller graph for this function: