ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Static Public Member Functions | List of all members
BigNumberUtil Class Reference

Utilities to assist with implementing big number arithmetic. More...

#include <BigNumberUtil.h>

Static Public Member Functions

static void unpackLE (limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
 Unpacks the little-endian byte representation of a big number into a limb array. More...
 
static void unpackBE (limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
 Unpacks the big-endian byte representation of a big number into a limb array. More...
 
static void packLE (uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
 Packs the little-endian byte representation of a big number into a byte array. More...
 
static void packBE (uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
 Packs the big-endian byte representation of a big number into a byte array. More...
 

Detailed Description

Utilities to assist with implementing big number arithmetic.

Big numbers are represented as arrays of limb_t words, which may be 8 bits, 16 bits, or 32 bits in size depending upon how the library was configured. For AVR, 16 bit limbs usually give the best performance.

Limb arrays are ordered from the least significant word to the most significant.

Definition at line 52 of file BigNumberUtil.h.

Member Function Documentation

void BigNumberUtil::packBE ( uint8_t *  bytes,
size_t  len,
const limb_t *  limbs,
size_t  count 
)
static

Packs the big-endian byte representation of a big number into a byte array.

Parameters
bytesThe byte array to pack into.
lenThe number of bytes in the destination bytes array.
limbsThe limb array representing the big number, starting with the least significant word.
countThe number of elements in the limbs array.

If len is shorter than the length of limbs, then the number will be truncated to the least significant len bytes. If len is longer than the length of limbs, then the high bytes will be filled with zeroes.

See Also
unpackLE(), packBE()

Definition at line 293 of file BigNumberUtil.cpp.

void BigNumberUtil::packLE ( uint8_t *  bytes,
size_t  len,
const limb_t *  limbs,
size_t  count 
)
static

Packs the little-endian byte representation of a big number into a byte array.

Parameters
bytesThe byte array to pack into.
lenThe number of bytes in the destination bytes array.
limbsThe limb array representing the big number, starting with the least significant word.
countThe number of elements in the limbs array.

If len is shorter than the length of limbs, then the number will be truncated to the least significant len bytes. If len is longer than the length of limbs, then the high bytes will be filled with zeroes.

See Also
unpackLE(), packBE()

Definition at line 207 of file BigNumberUtil.cpp.

void BigNumberUtil::unpackBE ( limb_t *  limbs,
size_t  count,
const uint8_t *  bytes,
size_t  len 
)
static

Unpacks the big-endian byte representation of a big number into a limb array.

Parameters
limbsThe limb array, starting with the least significant word.
countThe number of elements in the limbs array.
bytesThe bytes to unpack.
lenThe number of bytes to unpack.

If len is shorter than the length of limbs, then the high bytes will be filled with zeroes. If len is longer than the length of limbs, then the high bytes will be truncated and lost.

See Also
packBE(), unpackLE()

Definition at line 133 of file BigNumberUtil.cpp.

void BigNumberUtil::unpackLE ( limb_t *  limbs,
size_t  count,
const uint8_t *  bytes,
size_t  len 
)
static

Unpacks the little-endian byte representation of a big number into a limb array.

Parameters
limbsThe limb array, starting with the least significant word.
countThe number of elements in the limbs array.
bytesThe bytes to unpack.
lenThe number of bytes to unpack.

If len is shorter than the length of limbs, then the high bytes will be filled with zeroes. If len is longer than the length of limbs, then the high bytes will be truncated and lost.

See Also
packLE(), unpackBE()

Definition at line 54 of file BigNumberUtil.cpp.


The documentation for this class was generated from the following files: