simple range bug fix in set and clear bit
This commit is contained in:
parent
95cd93ad4d
commit
7e82213b36
1 changed files with 2 additions and 2 deletions
|
@ -266,7 +266,7 @@ Base64 = (function () {
|
|||
* @param {Number} idx - The index to set.
|
||||
*/
|
||||
set_bit(idx) {
|
||||
if (idx < 0 || idx > this.length) {
|
||||
if (idx < 0 || idx >= this.length) {
|
||||
throw new RangeError("Cannot set bit outside the range of the BitVector.");
|
||||
}
|
||||
this.bits[Math.floor(idx / 32)] |= (1 << idx % 32);
|
||||
|
@ -277,7 +277,7 @@ Base64 = (function () {
|
|||
* @param {Number} idx - The index to clear.
|
||||
*/
|
||||
clear_bit(idx) {
|
||||
if (idx < 0 || idx > this.length) {
|
||||
if (idx < 0 || idx >= this.length) {
|
||||
throw new RangeError("Cannot clear bit outside the range of the BitVector.");
|
||||
}
|
||||
this.bits[Math.floor(idx / 32)] &= ~(1 << idx % 32);
|
||||
|
|
Loading…
Reference in a new issue