Class for managing a very large integer for double precision. More...
Public Types | |
typedef uint32_t | ChunkSize_t |
Size of each data chunk. | |
typedef uint64_t | MathSize_t |
Size of data chunk for math (Double size of ChunkSize_t) | |
Public Member Functions | |
FPLargeInt (void) noexcept | |
Default constructor. | |
FPLargeInt (uint32_t uBitsNeeded) noexcept | |
Constructor that sets to a default. | |
uint_t | is_zero (void) const noexcept |
Returns TRUE if the value is zero. | |
uint_t | is_not_zero (void) const noexcept |
Returns TRUE if the value is not zero. | |
void | init (uint32_t uBitsNeeded) noexcept |
Initialize the giant integer. | |
void | insert_bits_at_end (uint32_t uBits, uint32_t uShiftAmount) noexcept |
Insert bits into the buffer. | |
void | insert_bits_at_start (uint32_t uBits, uint32_t uShiftAmount) noexcept |
Insert bits into the buffer from the top. | |
uint32_t | divide_return_remainder (uint32_t uDivisor) noexcept |
Divide the long number and return the remainder. | |
uint32_t | multiply_return_overflow (uint32_t uMultiplier) noexcept |
Multiply by multiplier and return the overflow, from 0 to div-1. | |
Static Public Attributes | |
static constexpr const uint32_t | kBitsPerElement |
Number of bits per uint32_t. | |
static constexpr const uint32_t | kTotalBitsInTable = 1024 + 64 |
Number of bits in the table to handle double precision. | |
static constexpr const uint32_t | kMaxElements |
Number of elements in the data table. | |
Protected Member Functions | |
void | insert_chunk_bits (ChunkSize_t uBits, uint32_t uEntryIndex) noexcept |
Do the actual work of inserting bits, and updating zero flag, and extents. | |
Protected Attributes | |
uint32_t | m_uEntryCount |
Number of entries in the data table. | |
int32_t | m_iHighestNonZeroElement |
Highest index with a non-zero entry in the data table. | |
int32_t | m_iLowestNonZeroElement |
Lowest index with a non-zero entry in the data table. | |
uint32_t | m_bIsZero |
TRUE if a zero length buffer | |
ChunkSize_t | m_uDataTable [kMaxElements] |
Data table of bits for locating digits. | |
Class for managing a very large integer for double precision.
This class is useful in parsing high precision numbers and can help in decoding floating point numbers for eventual conversion into a string. A double has up to 2048+53 bits of precision with half in the integer range and the other half in the fractional range. This class handles 1024+64 bits to be able to handle the entire fractional or integer range for ultra high precision double to ASCII conversion.
It can perform modulo and multiplication across all bits of precision. Since this class was designed for high precision integer to ASCII conversion, the two main functions are multiply_return_overflow() to parse out digits from the fractional side of a fixed point number and divide_return_remainder() to extract digits from the integer side of the fixed point number.
uint32_t Burger::FPLargeInt::ChunkSize_t |
Size of each data chunk.
uint64_t Burger::FPLargeInt::MathSize_t |
Size of data chunk for math (Double size of ChunkSize_t)
|
noexcept |
Default constructor.
|
explicitnoexcept |
Constructor that sets to a default.
uBitsNeeded | Number of bits of precision |
|
noexcept |
Divide the long number and return the remainder.
Given a value to perform a modulo, perform the modulo and return the remainder and leave the dividend in the data array
If uDivisor was 0, this function does nothing and returns zero
uDivisor | 32 bit unsigned number to divide the long integer |
|
noexcept |
Initialize the giant integer.
Reset the giant integer to defaults assuming a bit size
The maximum input value is kTotalBitsInTable -1
uBitsNeeded | Number of bits of precision 1 through ( kTotalBitsInTable -1) |
|
noexcept |
Insert bits into the buffer.
Insert the bits from value into m_uDataTable, shifted in from the end of the array by the specified number of bits. A shift of zero or less means that none of the bits will be shifted in. A shift of one means that the high bit of value will be in the bottom of the last element of m_uDataTable; the least significant bit. A shift of kBitsPerElement means that value will be in the least significant element of m_uDataTable, and so on. It's possible a large value can be shifted out.
uBits | 32 bit data to shift in. |
uShiftAmount | Number of bits to shift (0 to kTotalBitsInTable) |
|
noexcept |
Insert bits into the buffer from the top.
Insert the bits from value into m_uDataTable, shifted in from the beginning of the array by the specified number of bits. A shift of zero or less means that none of the bits will be shifted in. A shift of one means that the low bit of value will be in the top of the first element of m_uDataTable; the most significant bit. A shift of kBitsPerElement means that value will be in the most significant element of m_uDataTable, and so on.
uBits | 32 bit data to shift in |
uShiftAmount | Number of bits to shift (0 to kTotalBitsInTable) |
|
protectednoexcept |
Do the actual work of inserting bits, and updating zero flag, and extents.
uBits | 32 bit data to shift in |
uEntryIndex | Index into the entry table |
|
inlinenoexcept |
Returns TRUE if the value is not zero.
If the giant integer's value is not zero, return TRUE
|
inlinenoexcept |
Returns TRUE if the value is zero.
If the giant integer's value is zero, return TRUE
|
noexcept |
Multiply by multiplier and return the overflow, from 0 to div-1.
Multiply the giant integer with a number and return the number that overflowed out.
uMultiplier | Value to multiply the giant integer with |
|
staticconstexpr |
Number of bits per uint32_t.
|
staticconstexpr |
Number of elements in the data table.
|
staticconstexpr |
Number of bits in the table to handle double precision.
|
protected |
TRUE if a zero length buffer
|
protected |
Highest index with a non-zero entry in the data table.
|
protected |
Lowest index with a non-zero entry in the data table.
|
protected |
Data table of bits for locating digits.
|
protected |
Number of entries in the data table.