Category talk:Wren-big: Difference between revisions
→Source code: Added testBit method to BigInt.
(→Source code: Bug fix.) |
(→Source code: Added testBit method to BigInt.) |
||
Line 1,235:
if (n.isZero) return BigInt.zero
return BigInt.new(BigInt.integerLogarithm_(n, BigInt.two)[1]) + BigInt.one
}
// Returns true if the 'n'th bit of the current instance is set or false otherwise.
testBit(n) {
if (n.type != Num || !n.isInteger || n < 0) Fiber.abort("Argument must be a non-negative integer.")
return (this >> n) & BigInt.one != BigInt.zero
}
|