MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / getBitRangeAsInt

Method getBitRangeAsInt

JUCE/modules/juce_core/maths/juce_BigInteger.cpp:239–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239uint32 BigInteger::getBitRangeAsInt (const int startBit, int numBits) const noexcept
240{
241 if (numBits > 32)
242 {
243 jassertfalse; // use getBitRange() if you need more than 32 bits..
244 numBits = 32;
245 }
246
247 numBits = jmin (numBits, highestBit + 1 - startBit);
248
249 if (numBits <= 0)
250 return 0;
251
252 auto pos = bitToIndex (startBit);
253 auto offset = startBit & 31;
254 auto endSpace = 32 - numBits;
255 auto* values = getValues();
256
257 auto n = ((uint32) values [pos]) >> offset;
258
259 if (offset > endSpace)
260 n |= ((uint32) values [pos + 1]) << (32 - offset);
261
262 return n & (((uint32) 0xffffffff) >> endSpace);
263}
264
265void BigInteger::setBitRangeAsInt (const int startBit, int numBits, uint32 valueToSet)
266{

Callers 3

bigSieveFunction · 0.45
isProbablyPrimeMethod · 0.45
toStringMethod · 0.45

Calls 2

jminFunction · 0.85
bitToIndexFunction · 0.85

Tested by

no test coverage detected