Bug reported by Brad Spencer.
void BigUnsigned::setBit(Index bi, bool newBit) {
Index blockI = bi / N;
void BigUnsigned::setBit(Index bi, bool newBit) {
Index blockI = bi / N;
- Blk block = getBlock(blockI), mask = 1 << (bi % N);
+ Blk block = getBlock(blockI), mask = Blk(1) << (bi % N);
block = newBit ? (block | mask) : (block & ~mask);
setBlock(blockI, block);
}
block = newBit ? (block | mask) : (block & ~mask);
setBlock(blockI, block);
}
/* Get the state of bit bi, which has value 2^bi. Bits beyond the
* number's length are considered to be 0. */
bool getBit(Index bi) const {
/* Get the state of bit bi, which has value 2^bi. Bits beyond the
* number's length are considered to be 0. */
bool getBit(Index bi) const {
- return (getBlock(bi / N) & (1 << (bi % N))) != 0;
+ return (getBlock(bi / N) & (Blk(1) << (bi % N))) != 0;
}
/* Sets the state of bit bi to newBit. The number grows or shrinks as
* necessary. */
}
/* Sets the state of bit bi to newBit. The number grows or shrinks as
* necessary. */
+- BigUnsigned::{get,set}Bit: Change two remaining `1 <<' to `Blk(1) <<' to work
+ on systems where sizeof(unsigned int) != sizeof(Blk). Bug reported by Brad
+ Spencer.
- dataToBigInteger: Change a `delete' to `delete []' to avoid leaking memory.
Bug reported by Nicolás Carrasco.
- dataToBigInteger: Change a `delete' to `delete []' to avoid leaking memory.
Bug reported by Nicolás Carrasco.
- The old {BigUnsigned,BigInteger}::{divide,modulo} copy-less options have been
removed. Use divideWithRemainder instead.
- Added a base argument to BigUnsignedInABase's digit-array constructor. I
- The old {BigUnsigned,BigInteger}::{divide,modulo} copy-less options have been
removed. Use divideWithRemainder instead.
- Added a base argument to BigUnsignedInABase's digit-array constructor. I
- hope no one used that constructor in its broken state anyway.
+ ope no one used that constructor in its broken state anyway.
Other notable changes:
- Added BigUnsigned functions setBlock, bitLength, getBit, setBit.
Other notable changes:
- Added BigUnsigned functions setBlock, bitLength, getBit, setBit.