openshot-audio  0.1.5
Public Member Functions | List of all members
juce::BigInteger Class Reference

#include <juce_core.h>

Public Member Functions

 BigInteger ()
 
 BigInteger (uint32 value)
 
 BigInteger (int32 value)
 
 BigInteger (int64 value)
 
 BigInteger (const BigInteger &)
 
 ~BigInteger ()
 
BigIntegeroperator= (const BigInteger &)
 
void swapWith (BigInteger &) noexcept
 
bool operator[] (int bit) const noexcept
 
bool isZero () const noexcept
 
bool isOne () const noexcept
 
int toInteger () const noexcept
 
int64 toInt64 () const noexcept
 
void clear ()
 
void clearBit (int bitNumber) noexcept
 
void setBit (int bitNumber)
 
void setBit (int bitNumber, bool shouldBeSet)
 
void setRange (int startBit, int numBits, bool shouldBeSet)
 
void insertBit (int bitNumber, bool shouldBeSet)
 
BigInteger getBitRange (int startBit, int numBits) const
 
uint32 getBitRangeAsInt (int startBit, int numBits) const noexcept
 
void setBitRangeAsInt (int startBit, int numBits, uint32 valueToSet)
 
void shiftBits (int howManyBitsLeft, int startBit)
 
int countNumberOfSetBits () const noexcept
 
int findNextSetBit (int startIndex) const noexcept
 
int findNextClearBit (int startIndex) const noexcept
 
int getHighestBit () const noexcept
 
BigIntegeroperator+= (const BigInteger &)
 
BigIntegeroperator-= (const BigInteger &)
 
BigIntegeroperator*= (const BigInteger &)
 
BigIntegeroperator/= (const BigInteger &)
 
BigIntegeroperator|= (const BigInteger &)
 
BigIntegeroperator &= (const BigInteger &)
 
BigIntegeroperator^= (const BigInteger &)
 
BigIntegeroperator%= (const BigInteger &)
 
BigIntegeroperator<<= (int numBitsToShift)
 
BigIntegeroperator>>= (int numBitsToShift)
 
BigIntegeroperator++ ()
 
BigIntegeroperator-- ()
 
BigInteger operator++ (int)
 
BigInteger operator-- (int)
 
BigInteger operator- () const
 
BigInteger operator+ (const BigInteger &) const
 
BigInteger operator- (const BigInteger &) const
 
BigInteger operator* (const BigInteger &) const
 
BigInteger operator/ (const BigInteger &) const
 
BigInteger operator| (const BigInteger &) const
 
BigInteger operator & (const BigInteger &) const
 
BigInteger operator^ (const BigInteger &) const
 
BigInteger operator% (const BigInteger &) const
 
BigInteger operator<< (int numBitsToShift) const
 
BigInteger operator>> (int numBitsToShift) const
 
bool operator== (const BigInteger &) const noexcept
 
bool operator!= (const BigInteger &) const noexcept
 
bool operator< (const BigInteger &) const noexcept
 
bool operator<= (const BigInteger &) const noexcept
 
bool operator> (const BigInteger &) const noexcept
 
bool operator>= (const BigInteger &) const noexcept
 
int compare (const BigInteger &other) const noexcept
 
int compareAbsolute (const BigInteger &other) const noexcept
 
void divideBy (const BigInteger &divisor, BigInteger &remainder)
 
BigInteger findGreatestCommonDivisor (BigInteger other) const
 
void exponentModulo (const BigInteger &exponent, const BigInteger &modulus)
 
void inverseModulo (const BigInteger &modulus)
 
bool isNegative () const noexcept
 
void setNegative (bool shouldBeNegative) noexcept
 
void negate () noexcept
 
String toString (int base, int minimumNumCharacters=1) const
 
void parseString (StringRef text, int base)
 
MemoryBlock toMemoryBlock () const
 
void loadFromMemoryBlock (const MemoryBlock &data)
 

Detailed Description

An arbitrarily large integer class.

A BigInteger can be used in a similar way to a normal integer, but has no size limit (except for memory and performance constraints).

Negative values are possible, but the value isn't stored as 2s-complement, so be careful if you use negative values and look at the values of individual bits.

Constructor & Destructor Documentation

◆ BigInteger() [1/5]

BigInteger::BigInteger ( )

Creates an empty BigInteger

◆ BigInteger() [2/5]

BigInteger::BigInteger ( uint32  value)

Creates a BigInteger containing an integer value in its low bits. The low 32 bits of the number are initialised with this value.

◆ BigInteger() [3/5]

BigInteger::BigInteger ( int32  value)

Creates a BigInteger containing an integer value in its low bits. The low 32 bits of the number are initialised with the absolute value passed in, and its sign is set to reflect the sign of the number.

◆ BigInteger() [4/5]

BigInteger::BigInteger ( int64  value)

Creates a BigInteger containing an integer value in its low bits. The low 64 bits of the number are initialised with the absolute value passed in, and its sign is set to reflect the sign of the number.

◆ BigInteger() [5/5]

BigInteger::BigInteger ( const BigInteger other)

Creates a copy of another BigInteger.

◆ ~BigInteger()

BigInteger::~BigInteger ( )

Destructor.

Member Function Documentation

◆ clear()

void BigInteger::clear ( )

Resets the value to 0.

◆ clearBit()

void BigInteger::clearBit ( int  bitNumber)
noexcept

Clears a particular bit in the number.

◆ compare()

int BigInteger::compare ( const BigInteger other) const
noexcept

Does a signed comparison of two BigIntegers.

Return values are:

  • 0 if the numbers are the same
  • < 0 if this number is smaller than the other
  • > 0 if this number is bigger than the other

◆ compareAbsolute()

int BigInteger::compareAbsolute ( const BigInteger other) const
noexcept

Compares the magnitudes of two BigIntegers, ignoring their signs.

Return values are:

  • 0 if the numbers are the same
  • < 0 if this number is smaller than the other
  • > 0 if this number is bigger than the other

◆ countNumberOfSetBits()

int BigInteger::countNumberOfSetBits ( ) const
noexcept

Returns the total number of set bits in the value.

◆ divideBy()

void BigInteger::divideBy ( const BigInteger divisor,
BigInteger remainder 
)

Divides this value by another one and returns the remainder.

This number is divided by other, leaving the quotient in this number, with the remainder being copied to the other BigInteger passed in.

◆ exponentModulo()

void BigInteger::exponentModulo ( const BigInteger exponent,
const BigInteger modulus 
)

Performs a combined exponent and modulo operation. This BigInteger's value becomes (this ^ exponent) % modulus.

◆ findGreatestCommonDivisor()

BigInteger BigInteger::findGreatestCommonDivisor ( BigInteger  other) const

Returns the largest value that will divide both this value and the one passed-in.

◆ findNextClearBit()

int BigInteger::findNextClearBit ( int  startIndex) const
noexcept

Looks for the index of the next clear bit after a given starting point.

This searches from startIndex (inclusive) upwards for the first clear bit, and returns its index.

◆ findNextSetBit()

int BigInteger::findNextSetBit ( int  startIndex) const
noexcept

Looks for the index of the next set bit after a given starting point.

This searches from startIndex (inclusive) upwards for the first set bit, and returns its index. If no set bits are found, it returns -1.

◆ getBitRange()

BigInteger BigInteger::getBitRange ( int  startBit,
int  numBits 
) const

Returns a range of bits as a new BigInteger.

e.g. getBitRangeAsInt (0, 64) would return the lowest 64 bits.

See also
getBitRangeAsInt

◆ getBitRangeAsInt()

uint32 BigInteger::getBitRangeAsInt ( int  startBit,
int  numBits 
) const
noexcept

Returns a range of bits as an integer value.

e.g. getBitRangeAsInt (0, 32) would return the lowest 32 bits.

Asking for more than 32 bits isn't allowed (obviously) - for that, use getBitRange().

◆ getHighestBit()

int BigInteger::getHighestBit ( ) const
noexcept

Returns the index of the highest set bit in the number. If the value is zero, this will return -1.

◆ insertBit()

void BigInteger::insertBit ( int  bitNumber,
bool  shouldBeSet 
)

Inserts a bit an a given position, shifting up any bits above it.

◆ inverseModulo()

void BigInteger::inverseModulo ( const BigInteger modulus)

Performs an inverse modulo on the value. i.e. the result is (this ^ -1) mod (modulus).

◆ isNegative()

bool BigInteger::isNegative ( ) const
noexcept

Returns true if the value is less than zero.

See also
setNegative, negate

◆ isOne()

bool BigInteger::isOne ( ) const
noexcept

Returns true if the value is 1.

◆ isZero()

bool BigInteger::isZero ( ) const
noexcept

Returns true if no bits are set.

◆ loadFromMemoryBlock()

void BigInteger::loadFromMemoryBlock ( const MemoryBlock data)

Converts a block of raw data into a number.

The data is arranged as little-endian, so the first byte of data is the low 8 bits of the number, and so on.

See also
toMemoryBlock

◆ negate()

void BigInteger::negate ( )
noexcept

Inverts the sign of the number.

See also
isNegative, setNegative

◆ operator &()

BigInteger juce::BigInteger::operator& ( const BigInteger ) const

◆ operator &=()

BigInteger& juce::BigInteger::operator&= ( const BigInteger )

◆ operator!=()

bool BigInteger::operator!= ( const BigInteger other) const
noexcept

◆ operator%()

BigInteger BigInteger::operator% ( const BigInteger other) const

◆ operator%=()

BigInteger & BigInteger::operator%= ( const BigInteger divisor)

◆ operator*()

BigInteger BigInteger::operator* ( const BigInteger other) const

◆ operator*=()

BigInteger & BigInteger::operator*= ( const BigInteger other)

◆ operator+()

BigInteger BigInteger::operator+ ( const BigInteger other) const

◆ operator++() [1/2]

BigInteger & BigInteger::operator++ ( )

◆ operator++() [2/2]

BigInteger BigInteger::operator++ ( int  )

◆ operator+=()

BigInteger & BigInteger::operator+= ( const BigInteger other)

◆ operator-() [1/2]

BigInteger BigInteger::operator- ( ) const

◆ operator-() [2/2]

BigInteger BigInteger::operator- ( const BigInteger other) const

◆ operator--() [1/2]

BigInteger & BigInteger::operator-- ( )

◆ operator--() [2/2]

BigInteger BigInteger::operator-- ( int  )

◆ operator-=()

BigInteger & BigInteger::operator-= ( const BigInteger other)

◆ operator/()

BigInteger BigInteger::operator/ ( const BigInteger other) const

◆ operator/=()

BigInteger & BigInteger::operator/= ( const BigInteger other)

◆ operator<()

bool BigInteger::operator< ( const BigInteger other) const
noexcept

◆ operator<<()

BigInteger BigInteger::operator<< ( int  numBitsToShift) const

◆ operator<<=()

BigInteger & BigInteger::operator<<= ( int  numBitsToShift)

◆ operator<=()

bool BigInteger::operator<= ( const BigInteger other) const
noexcept

◆ operator=()

BigInteger & BigInteger::operator= ( const BigInteger other)

Copies another BigInteger onto this one.

◆ operator==()

bool BigInteger::operator== ( const BigInteger other) const
noexcept

◆ operator>()

bool BigInteger::operator> ( const BigInteger other) const
noexcept

◆ operator>=()

bool BigInteger::operator>= ( const BigInteger other) const
noexcept

◆ operator>>()

BigInteger BigInteger::operator>> ( int  numBitsToShift) const

◆ operator>>=()

BigInteger & BigInteger::operator>>= ( int  numBitsToShift)

◆ operator[]()

bool BigInteger::operator[] ( int  bit) const
noexcept

Returns the value of a specified bit in the number. If the index is out-of-range, the result will be false.

◆ operator^()

BigInteger BigInteger::operator^ ( const BigInteger other) const

◆ operator^=()

BigInteger & BigInteger::operator^= ( const BigInteger other)

◆ operator|()

BigInteger BigInteger::operator| ( const BigInteger other) const

◆ operator|=()

BigInteger & BigInteger::operator|= ( const BigInteger other)

◆ parseString()

void BigInteger::parseString ( StringRef  text,
int  base 
)

Reads the numeric value from a string.

Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex). Any invalid characters will be ignored.

◆ setBit() [1/2]

void BigInteger::setBit ( int  bitNumber)

Sets a specified bit to 1.

◆ setBit() [2/2]

void BigInteger::setBit ( int  bitNumber,
bool  shouldBeSet 
)

Sets or clears a specified bit.

◆ setBitRangeAsInt()

void BigInteger::setBitRangeAsInt ( int  startBit,
int  numBits,
uint32  valueToSet 
)

Sets a range of bits to an integer value.

Copies the given integer onto a range of bits, starting at startBit, and using up to numBits of the available bits.

◆ setNegative()

void BigInteger::setNegative ( bool  shouldBeNegative)
noexcept

Changes the sign of the number to be positive or negative.

See also
isNegative, negate

◆ setRange()

void BigInteger::setRange ( int  startBit,
int  numBits,
bool  shouldBeSet 
)

Sets a range of bits to be either on or off.

Parameters
startBitthe first bit to change
numBitsthe number of bits to change
shouldBeSetwhether to turn these bits on or off

◆ shiftBits()

void BigInteger::shiftBits ( int  howManyBitsLeft,
int  startBit 
)

Shifts a section of bits left or right.

Parameters
howManyBitsLefthow far to move the bits (+ve numbers shift it left, -ve numbers shift it right).
startBitthe first bit to affect - if this is > 0, only bits above that index will be affected.

◆ swapWith()

void BigInteger::swapWith ( BigInteger other)
noexcept

Swaps the internal contents of this with another object.

◆ toInt64()

int64 BigInteger::toInt64 ( ) const
noexcept

Attempts to get the lowest 64 bits of the value as an integer. If the value is bigger than the integer limits, this will return only the lower bits.

◆ toInteger()

int BigInteger::toInteger ( ) const
noexcept

Attempts to get the lowest 32 bits of the value as an integer. If the value is bigger than the integer limits, this will return only the lower bits.

◆ toMemoryBlock()

MemoryBlock BigInteger::toMemoryBlock ( ) const

Turns the number into a block of binary data.

The data is arranged as little-endian, so the first byte of data is the low 8 bits of the number, and so on.

See also
loadFromMemoryBlock

◆ toString()

String BigInteger::toString ( int  base,
int  minimumNumCharacters = 1 
) const

Converts the number to a string.

Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex). If minimumNumCharacters is greater than 0, the returned string will be padded with leading zeros to reach at least that length.


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