28 inline uint32 bitToMask (
const int bit)
noexcept {
return (
uint32) 1 << (bit & 31); }
29 inline size_t bitToIndex (
const int bit)
noexcept {
return (
size_t) (bit >> 5); }
30 inline size_t sizeNeededToHold (
int highestBit)
noexcept {
return (
size_t) (highestBit >> 5) + 1; }
37 #if JUCE_GCC || JUCE_CLANG
38 return 31 - __builtin_clz (n);
40 unsigned long highest;
41 _BitScanReverse (&highest, n);
55 : allocatedSize (numPreallocatedInts)
57 for (
int i = 0; i < numPreallocatedInts; ++i)
62 : allocatedSize (numPreallocatedInts),
66 preallocated[0] = (
uint32) std::abs (value);
68 for (
int i = 1; i < numPreallocatedInts; ++i)
75 : allocatedSize (numPreallocatedInts),
78 preallocated[0] = value;
80 for (
int i = 1; i < numPreallocatedInts; ++i)
87 : allocatedSize (numPreallocatedInts),
94 preallocated[0] = (
uint32) value;
95 preallocated[1] = (
uint32) (value >> 32);
97 for (
int i = 2; i < numPreallocatedInts; ++i)
104 : allocatedSize (other.allocatedSize),
105 highestBit (other.getHighestBit()),
106 negative (other.negative)
108 if (allocatedSize > numPreallocatedInts)
109 heapAllocation.
malloc (allocatedSize);
111 memcpy (getValues(), other.getValues(), sizeof (
uint32) * allocatedSize);
115 : heapAllocation (std::move (other.heapAllocation)),
116 allocatedSize (other.allocatedSize),
117 highestBit (other.highestBit),
118 negative (other.negative)
120 memcpy (preallocated, other.preallocated, sizeof (preallocated));
125 heapAllocation = std::move (other.heapAllocation);
126 memcpy (preallocated, other.preallocated, sizeof (preallocated));
127 allocatedSize = other.allocatedSize;
128 highestBit = other.highestBit;
129 negative = other.negative;
135 for (
int i = 0; i < numPreallocatedInts; ++i)
136 std::swap (preallocated[i], other.preallocated[i]);
138 heapAllocation.swapWith (other.heapAllocation);
139 std::swap (allocatedSize, other.allocatedSize);
140 std::swap (highestBit, other.highestBit);
149 auto newAllocatedSize = (
size_t)
jmax ((
size_t) numPreallocatedInts, sizeNeededToHold (highestBit));
151 if (newAllocatedSize <= numPreallocatedInts)
152 heapAllocation.
free();
153 else if (newAllocatedSize != allocatedSize)
154 heapAllocation.
malloc (newAllocatedSize);
156 allocatedSize = newAllocatedSize;
158 memcpy (getValues(), other.getValues(), sizeof (
uint32) * allocatedSize);
159 negative = other.negative;
167uint32* BigInteger::getValues() const noexcept
169 jassert (heapAllocation !=
nullptr || allocatedSize <= numPreallocatedInts);
171 return heapAllocation !=
nullptr ? heapAllocation
172 :
const_cast<uint32*
> (preallocated);
175uint32* BigInteger::ensureSize (
const size_t numVals)
177 if (numVals > allocatedSize)
179 auto oldSize = allocatedSize;
180 allocatedSize = ((numVals + 2) * 3) / 2;
182 if (heapAllocation ==
nullptr)
184 heapAllocation.
calloc (allocatedSize);
185 memcpy (heapAllocation, preallocated,
sizeof (
uint32) * numPreallocatedInts);
189 heapAllocation.
realloc (allocatedSize);
191 for (
auto* values = getValues(); oldSize < allocatedSize; ++oldSize)
202 return bit <= highestBit && bit >= 0
203 && ((getValues() [bitToIndex (bit)] & bitToMask (bit)) != 0);
208 auto n = (
int) (getValues()[0] & 0x7fffffff);
209 return negative ? -n : n;
214 auto* values = getValues();
215 auto n = (((
int64) (values[1] & 0x7fffffff)) << 32) | values[0];
216 return negative ? -n : n;
223 auto* destValues = r.ensureSize (sizeNeededToHold (numBits));
224 r.highestBit = numBits;
226 for (
int i = 0; numBits > 0;)
245 numBits =
jmin (numBits, highestBit + 1 - startBit);
250 auto pos = bitToIndex (startBit);
251 auto offset = startBit & 31;
252 auto endSpace = 32 - numBits;
253 auto* values = getValues();
255 auto n = ((
uint32) values [pos]) >> offset;
257 if (offset > endSpace)
258 n |= ((
uint32) values [pos + 1]) << (32 - offset);
260 return n & (((
uint32) 0xffffffff) >> endSpace);
271 for (
int i = 0; i < numBits; ++i)
273 setBit (startBit + i, (valueToSet & 1) != 0);
283 heapAllocation.
free();
284 allocatedSize = numPreallocatedInts;
288 for (
int i = 0; i < numPreallocatedInts; ++i)
298 if (bit > highestBit)
300 ensureSize (sizeNeededToHold (bit));
304 getValues() [bitToIndex (bit)] |= bitToMask (bit);
322 if (bit >= 0 && bit <= highestBit)
324 getValues() [bitToIndex (bit)] &= ~bitToMask (bit);
326 if (bit == highestBit)
327 highestBit = getHighestBit();
335 while (--numBits >= 0)
336 setBit (startBit++, shouldBeSet);
346 setBit (bit, shouldBeSet);
363 return negative && !
isZero();
373 negative = (! negative) && !
isZero();
376#if JUCE_MSVC && ! defined (__INTEL_COMPILER)
377 #pragma intrinsic (_BitScanReverse)
383 auto* values = getValues();
385 for (
int i = (
int) sizeNeededToHold (highestBit); --i >= 0;)
393 auto* values = getValues();
395 for (
int i = (
int) bitToIndex (highestBit); i >= 0; --i)
404 auto* values = getValues();
406 for (; i <= highestBit; ++i)
407 if ((values [bitToIndex (i)] & bitToMask (i)) != 0)
415 auto* values = getValues();
417 for (; i <= highestBit; ++i)
418 if ((values [bitToIndex (i)] & bitToMask (i)) == 0)
431 return operator-= (-other);
451 highestBit =
jmax (highestBit, other.highestBit) + 1;
453 auto numInts = sizeNeededToHold (highestBit);
454 auto* values = ensureSize (numInts);
455 auto* otherValues = other.getValues();
458 for (
size_t i = 0; i < numInts; ++i)
462 if (i < other.allocatedSize)
465 values[i] = (
uint32) remainder;
476BigInteger& BigInteger::operator-= (
const BigInteger& other)
484 if (other.isNegative())
485 return operator+= (-other);
505 auto maxOtherInts = sizeNeededToHold (other.getHighestBit());
506 jassert (numInts >= maxOtherInts);
507 auto* values = getValues();
508 auto* otherValues = other.getValues();
509 int64 amountToSubtract = 0;
511 for (
size_t i = 0; i < numInts; ++i)
513 if (i < maxOtherInts)
514 amountToSubtract += (
int64) otherValues[i];
516 if (values[i] >= amountToSubtract)
518 values[i] = (
uint32) (values[i] - amountToSubtract);
519 amountToSubtract = 0;
523 const int64 n = ((
int64) values[i] + (((
int64) 1) << 32)) - amountToSubtract;
525 amountToSubtract = 1;
533BigInteger& BigInteger::operator*= (
const BigInteger& other)
539 auto t = other.getHighestBit();
545 total.highestBit = n + t + 1;
546 auto* totalValues = total.ensureSize (sizeNeededToHold (total.highestBit) + 1);
552 m.setNegative (
false);
554 auto* mValues = m.getValues();
555 auto* values = getValues();
557 for (
int i = 0; i <= t; ++i)
561 for (
int j = 0; j <= n; ++j)
564 totalValues[i + j] = (
uint32) uv;
565 c =
static_cast<uint32> (uv >> 32);
568 totalValues[i + n + 1] = c;
571 total.highestBit = total.getHighestBit();
572 total.setNegative (wasNegative ^ other.isNegative());
580 if (
this == &divisor)
588 if (divHB < 0 || ourHB < 0)
605 auto leftShift = ourHB - divHB;
608 while (leftShift >= 0)
610 if (
remainder.compareAbsolute (temp) >= 0)
616 if (--leftShift >= 0)
620 negative = wasNegative ^ divisor.
isNegative();
632BigInteger& BigInteger::operator|= (
const BigInteger& other)
640 if (other.highestBit >= 0)
642 auto* values = ensureSize (sizeNeededToHold (other.highestBit));
643 auto* otherValues = other.getValues();
645 auto n = (
int) bitToIndex (other.highestBit) + 1;
648 values[n] |= otherValues[n];
650 if (other.highestBit > highestBit)
651 highestBit = other.highestBit;
659BigInteger& BigInteger::operator&= (
const BigInteger& other)
667 auto* values = getValues();
668 auto* otherValues = other.getValues();
670 auto n = (
int) allocatedSize;
672 while (n > (
int) other.allocatedSize)
676 values[n] &= otherValues[n];
678 if (other.highestBit < highestBit)
679 highestBit = other.highestBit;
685BigInteger& BigInteger::operator^= (
const BigInteger& other)
696 if (other.highestBit >= 0)
698 auto* values = ensureSize (sizeNeededToHold (other.highestBit));
699 auto* otherValues = other.getValues();
701 auto n = (
int) bitToIndex (other.highestBit) + 1;
704 values[n] ^= otherValues[n];
706 if (other.highestBit > highestBit)
707 highestBit = other.highestBit;
715BigInteger& BigInteger::operator%= (
const BigInteger& divisor)
723BigInteger& BigInteger::operator++() {
return operator+= (1); }
724BigInteger& BigInteger::operator--() {
return operator-= (1); }
725BigInteger BigInteger::operator++ (
int) {
const auto old (*
this); operator+= (1);
return old; }
726BigInteger BigInteger::operator-- (
int) {
const auto old (*
this); operator-= (1);
return old; }
728BigInteger BigInteger::operator-()
const {
auto b (*
this); b.negate();
return b; }
729BigInteger BigInteger::operator+ (
const BigInteger& other)
const {
auto b (*
this);
return b += other; }
730BigInteger BigInteger::operator- (
const BigInteger& other)
const {
auto b (*
this);
return b -= other; }
731BigInteger BigInteger::operator* (
const BigInteger& other)
const {
auto b (*
this);
return b *= other; }
732BigInteger BigInteger::operator/ (
const BigInteger& other)
const {
auto b (*
this);
return b /= other; }
733BigInteger BigInteger::operator| (
const BigInteger& other)
const {
auto b (*
this);
return b |= other; }
734BigInteger BigInteger::operator& (
const BigInteger& other)
const {
auto b (*
this);
return b &= other; }
735BigInteger BigInteger::operator^ (
const BigInteger& other)
const {
auto b (*
this);
return b ^= other; }
736BigInteger BigInteger::operator% (
const BigInteger& other)
const {
auto b (*
this);
return b %= other; }
737BigInteger BigInteger::operator<< (
const int numBits)
const {
auto b (*
this);
return b <<= numBits; }
738BigInteger BigInteger::operator>> (
const int numBits)
const {
auto b (*
this);
return b >>= numBits; }
739BigInteger& BigInteger::operator<<= (
const int numBits) {
shiftBits (numBits, 0);
return *
this; }
740BigInteger& BigInteger::operator>>= (
const int numBits) {
shiftBits (-numBits, 0);
return *
this; }
745 auto isNeg = isNegative();
747 if (isNeg == other.isNegative())
749 auto absComp = compareAbsolute (other);
750 return isNeg ? -absComp : absComp;
753 return isNeg ? -1 : 1;
758 auto h1 = getHighestBit();
759 auto h2 = other.getHighestBit();
761 if (h1 > h2)
return 1;
762 if (h1 < h2)
return -1;
764 auto* values = getValues();
765 auto* otherValues = other.getValues();
767 for (
int i = (
int) bitToIndex (h1); i >= 0; --i)
768 if (values[i] != otherValues[i])
769 return values[i] > otherValues[i] ? 1 : -1;
774bool BigInteger::operator== (
const BigInteger& other)
const noexcept {
return compare (other) == 0; }
775bool BigInteger::operator!= (
const BigInteger& other)
const noexcept {
return compare (other) != 0; }
776bool BigInteger::operator< (
const BigInteger& other)
const noexcept {
return compare (other) < 0; }
777bool BigInteger::operator<= (
const BigInteger& other)
const noexcept {
return compare (other) <= 0; }
778bool BigInteger::operator> (
const BigInteger& other)
const noexcept {
return compare (other) > 0; }
779bool BigInteger::operator>= (
const BigInteger& other)
const noexcept {
return compare (other) >= 0; }
782void BigInteger::shiftLeft (
int bits,
const int startBit)
786 for (
int i = highestBit; i >= startBit; --i)
787 setBit (i + bits, (*
this) [i]);
794 auto* values = ensureSize (sizeNeededToHold (highestBit + bits));
795 auto wordsToMove = bitToIndex (bits);
796 auto numOriginalInts = bitToIndex (highestBit);
801 for (
int i = (
int) numOriginalInts; i >= 0; --i)
802 values[(
size_t) i + wordsToMove] = values[i];
804 for (
size_t j = 0; j < wordsToMove; ++j)
812 auto invBits = 32 - bits;
814 for (
size_t i = bitToIndex (highestBit); i > wordsToMove; --i)
815 values[i] = (values[i] << bits) | (values[i - 1] >> invBits);
817 values[wordsToMove] = values[wordsToMove] << bits;
824void BigInteger::shiftRight (
int bits,
const int startBit)
828 for (
int i = startBit; i <= highestBit; ++i)
829 setBit (i, (*
this) [i + bits]);
835 if (bits > highestBit)
841 auto wordsToMove = bitToIndex (bits);
842 auto top = 1 + bitToIndex (highestBit) - wordsToMove;
844 auto* values = getValues();
848 for (
size_t i = 0; i < top; ++i)
849 values[i] = values[i + wordsToMove];
851 for (
size_t i = 0; i < wordsToMove; ++i)
859 auto invBits = 32 - bits;
862 for (
size_t i = 0; i < top; ++i)
863 values[i] = (values[i] >> bits) | (values[i + 1] << invBits);
865 values[top] = (values[top] >> bits);
878 shiftRight (-bits, startBit);
880 shiftLeft (bits, startBit);
907 return simpleGCD (&m, &n);
928 auto n =
exp.getHighestBit();
930 for (
int i = n; --i >= 0;)
945 R.shiftLeft (Rfactor, 0);
954 for (
int i =
exp.getHighestBit(); --i >= 0;)
967 auto am = (*
this * R) % modulus;
969 auto um = R % modulus;
971 for (
int i =
exp.getHighestBit(); --i >= 0;)
976 xm.montgomeryMultiplication (am, modulus, m1, Rfactor);
979 xm.montgomeryMultiplication (1, modulus, m1, Rfactor);
991 setRange (k, highestBit - k + 1,
false);
994 setRange (k, highestBit - k + 1,
false);
1011 while (! q.isZero())
1013 tempValues.
add (p / q);
1022 for (
int i = 1; i < tempValues.
size(); ++i)
1032 if (gcd.compareAbsolute (y * b - x * a) != 0)
1063 b1 (modulus), b2 (1);
1065 while (! a2.isOne())
1071 temp1 *= multiplier;
1078 temp1 *= multiplier;
1095 return stream << value.
toString (10);
1103 if (base == 2 || base == 8 || base == 16)
1105 auto bits = (base == 2) ? 1 : (base == 8 ? 3 : 4);
1106 static const char hexDigits[] =
"0123456789abcdef";
1110 auto remainder = v.getBitRangeAsInt (0, bits);
1119 else if (base == 10)
1140 s = s.
paddedLeft (
'0', minimumNumCharacters);
1152 if (base == 2 || base == 8 || base == 16)
1154 auto bits = (base == 2) ? 1 : (base == 8 ? 3 : 4);
1158 auto c = t.getAndAdvance();
1172 else if (base == 10)
1178 auto c = t.getAndAdvance();
1180 if (c >=
'0' && c <=
'9')
1183 *
this += (
int) (c -
'0');
1197 auto* values = getValues();
1199 for (
int i = 0; i < numBytes; ++i)
1200 mb[i] = (
char) ((values[i / 4] >> ((i & 3) * 8)) & 0xff);
1207 auto numBytes = data.getSize();
1208 auto numInts = 1 + (numBytes /
sizeof (
uint32));
1209 auto* values = ensureSize (numInts);
1211 for (
int i = 0; i < (
int) numInts - 1; ++i)
1214 values[numInts - 1] = 0;
1216 for (
int i = (
int) (numBytes & ~3u); i < (
int) numBytes; ++i)
1219 highestBit = (
int) numBytes * 8;
1227 jassert (numBits > 0 && numBits <= 32);
1228 jassert (numBits == 32 || (value >> numBits) == 0);
1230 uint8* data =
static_cast<uint8*
> (buffer) + startBit / 8;
1232 if (
const uint32 offset = (startBit & 7))
1234 const uint32 bitsInByte = 8 - offset;
1235 const uint8 current = *data;
1237 if (bitsInByte >= numBits)
1239 *data = (
uint8) ((current & ~(((1u << numBits) - 1u) << offset)) | (value << offset));
1243 *data++ = current ^ (
uint8) (((value << offset) ^ current) & (((1u << bitsInByte) - 1u) << offset));
1244 numBits -= bitsInByte;
1245 value >>= bitsInByte;
1248 while (numBits >= 8)
1250 *data++ = (
uint8) value;
1256 *data = (
uint8) ((*data & (
uint32) (0xff << numBits)) | value);
1262 jassert (numBits > 0 && numBits <= 32);
1266 const uint8* data =
static_cast<const uint8*
> (buffer) + startBit / 8;
1268 if (
const uint32 offset = (startBit & 7))
1270 const uint32 bitsInByte = 8 - offset;
1271 result = (
uint32) (*data >> offset);
1273 if (bitsInByte >= numBits)
1274 return result & ((1u << numBits) - 1u);
1276 numBits -= bitsInByte;
1277 bitsRead += bitsInByte;
1281 while (numBits >= 8)
1283 result |= (((
uint32) *data++) << bitsRead);
1289 result |= ((*data & ((1u << numBits) - 1u)) << bitsRead);
1299class BigIntegerTests final :
public UnitTest
1303 : UnitTest (
"BigInteger", UnitTestCategories::maths)
1306 static BigInteger getBigRandom (Random& r)
1311 r.fillBitsRandomly (b, 0, r.nextInt (150) + 1);
1316 void runTest()
override
1319 beginTest (
"BigInteger");
1321 Random r = getRandom();
1323 expect (BigInteger().isZero());
1324 expect (BigInteger (1).isOne());
1326 for (
int j = 10000; --j >= 0;)
1328 BigInteger b1 (getBigRandom (r)),
1329 b2 (getBigRandom (r));
1331 BigInteger b3 = b1 + b2;
1332 expect (b3 > b1 && b3 > b2);
1333 expect (b3 - b1 == b2);
1334 expect (b3 - b2 == b1);
1336 BigInteger b4 = b1 * b2;
1337 expect (b4 > b1 && b4 > b2);
1338 expect (b4 / b1 == b2);
1339 expect (b4 / b2 == b1);
1340 expect (((b4 << 1) >> 1) == b4);
1341 expect (((b4 << 10) >> 10) == b4);
1342 expect (((b4 << 100) >> 100) == b4);
1347 b5.loadFromMemoryBlock (b3.toMemoryBlock());
1353 beginTest (
"Bit setting");
1355 Random r = getRandom();
1356 static uint8 test[2048];
1358 for (
int j = 100000; --j >= 0;)
1360 uint32 offset =
static_cast<uint32
> (r.nextInt (200) + 10);
1361 uint32 num =
static_cast<uint32
> (r.nextInt (32) + 1);
1362 uint32 value =
static_cast<uint32
> (r.nextInt());
1365 value &= ((1u << num) - 1);
1372 expect (result == value);
1373 expect (old1 == readLittleEndianBitsInBuffer (test, offset - 6, 6));
1374 expect (old2 == readLittleEndianBitsInBuffer (test, offset + num, 6));
1380static BigIntegerTests bigIntegerTests;
Holds a resizable array of primitive or copy-by-value objects.
int size() const noexcept
Returns the current number of elements in the array.
void add(const ElementType &newElement)
Appends a new element at the end of the array.
ElementType & getReference(int index) noexcept
Returns a direct reference to one of the elements in the array, without checking the index passed in.
An arbitrarily large integer class.
BigInteger & clear() noexcept
Resets the value to 0.
MemoryBlock toMemoryBlock() const
Turns the number into a block of binary data.
bool isOne() const noexcept
Returns true if the value is 1.
BigInteger getBitRange(int startBit, int numBits) const
Returns a range of bits as a new BigInteger.
void parseString(StringRef text, int base)
Reads the numeric value from a string.
int64 toInt64() const noexcept
Attempts to get the lowest 64 bits of the value as an integer.
void exponentModulo(const BigInteger &exponent, const BigInteger &modulus)
Performs a combined exponent and modulo operation.
void setNegative(bool shouldBeNegative) noexcept
Changes the sign of the number to be positive or negative.
uint32 getBitRangeAsInt(int startBit, int numBits) const noexcept
Returns a range of bits as an integer value.
BigInteger & setRange(int startBit, int numBits, bool shouldBeSet)
Sets a range of bits to be either on or off.
BigInteger findGreatestCommonDivisor(BigInteger other) const
Returns the largest value that will divide both this value and the argument.
void extendedEuclidean(const BigInteger &a, const BigInteger &b, BigInteger &xOut, BigInteger &yOut)
Performs the Extended Euclidean algorithm.
int getHighestBit() const noexcept
Returns the index of the highest set bit in the number.
void divideBy(const BigInteger &divisor, BigInteger &remainder)
Divides this value by another one and returns the remainder.
String toString(int base, int minimumNumCharacters=1) const
Converts the number to a string.
BigInteger & shiftBits(int howManyBitsLeft, int startBit)
Shifts a section of bits left or right.
int findNextClearBit(int startIndex) const noexcept
Looks for the index of the next clear bit after a given starting point.
int compare(const BigInteger &other) const noexcept
Does a signed comparison of two BigIntegers.
BigInteger & insertBit(int bitNumber, bool shouldBeSet)
Inserts a bit an a given position, shifting up any bits above it.
BigInteger & setBitRangeAsInt(int startBit, int numBits, uint32 valueToSet)
Sets a range of bits to an integer value.
BigInteger & clearBit(int bitNumber) noexcept
Clears a particular bit in the number.
BigInteger()
Creates an empty BigInteger.
void negate() noexcept
Inverts the sign of the number.
int findNextSetBit(int startIndex) const noexcept
Looks for the index of the next set bit after a given starting point.
void loadFromMemoryBlock(const MemoryBlock &data)
Converts a block of raw data into a number.
bool isZero() const noexcept
Returns true if no bits are set.
int countNumberOfSetBits() const noexcept
Returns the total number of set bits in the value.
void swapWith(BigInteger &) noexcept
Swaps the internal contents of this with another object.
void montgomeryMultiplication(const BigInteger &other, const BigInteger &modulus, const BigInteger &modulusp, int k)
Performs the Montgomery Multiplication with modulo.
bool isNegative() const noexcept
Returns true if the value is less than zero.
bool operator[](int bit) const noexcept
Returns the value of a specified bit in the number.
int compareAbsolute(const BigInteger &other) const noexcept
Compares the magnitudes of two BigIntegers, ignoring their signs.
BigInteger & operator=(BigInteger &&) noexcept
Move assignment operator.
BigInteger & setBit(int bitNumber)
Sets a specified bit to 1.
int toInteger() const noexcept
Attempts to get the lowest 32 bits of the value as an integer.
void inverseModulo(const BigInteger &modulus)
Performs an inverse modulo on the value.
static constexpr uint32 littleEndianInt(const void *bytes) noexcept
Turns 4 bytes into a little-endian integer.
CharPointer_UTF8 findEndOfWhitespace() const noexcept
Returns the first non-whitespace character in the string.
static int getHexDigitValue(juce_wchar digit) noexcept
Returns 0 to 16 for '0' to 'F", or -1 for characters that aren't a legal hex digit.
void malloc(SizeType newNumElements, size_t elementSize=sizeof(ElementType))
Allocates a specified amount of memory.
void realloc(SizeType newNumElements, size_t elementSize=sizeof(ElementType))
Re-allocates a specified amount of memory.
void free() noexcept
Frees any currently-allocated data.
void calloc(SizeType newNumElements, const size_t elementSize=sizeof(ElementType))
Allocates a specified amount of memory and clears it.
A class to hold a resizable block of raw data.
The base class for streams that write data to some kind of destination.
A simple class for holding temporary references to a string literal or String.
String::CharPointerType text
The text that is referenced.
String paddedLeft(juce_wchar padCharacter, int minimumLength) const
Returns a copy of this string with the specified character repeatedly added to its beginning until th...
static String charToString(juce_wchar character)
Creates a string from a single character.
uint32 readLittleEndianBitsInBuffer(const void *buffer, uint32 startBit, uint32 numBits) noexcept
Reads a number of bits from a buffer at a given bit index.
wchar_t juce_wchar
A platform-independent 32-bit unicode character type.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
int findHighestSetBit(uint32 n) noexcept
Returns the index of the highest set bit in a (non-zero) number.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
signed int int32
A platform-independent 32-bit signed integer type.
void writeLittleEndianBitsInBuffer(void *buffer, uint32 startBit, uint32 numBits, uint32 value) noexcept
Writes a number of bits into a memory buffer at a given bit index.
constexpr int countNumberOfBits(uint32 n) noexcept
Returns the number of bits in a 32-bit integer.
OutputStream &JUCE_CALLTYPE operator<<(OutputStream &stream, const BigInteger &value)
Writes a BigInteger to an OutputStream as a UTF8 decimal string.
unsigned long long uint64
A platform-independent 64-bit unsigned integer type.
Type * addBytesToPointer(Type *basePointer, IntegerType bytes) noexcept
A handy function which adds a number of bytes to any type of pointer and returns the result.
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
long long int64
A platform-independent 64-bit integer type.