| 237 | } |
| 238 | |
| 239 | uint32 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 | |
| 265 | void BigInteger::setBitRangeAsInt (const int startBit, int numBits, uint32 valueToSet) |
| 266 | { |
no test coverage detected