circuitpython/tests/basics/int-big-and.py
Damien George f55cf10101 py: Implement bignum '&' with negatives on lhs and rhs.
Needs proper coverage testing.  Doesn't implement -ve & -ve.
Addresses issue #611.
2014-05-29 15:01:49 +01:00

25 lines
557 B
Python

print(0 & (1 << 80))
print(0 & (1 << 80) == 0)
print(bool(0 & (1 << 80)))
a = 0xfffffffffffffffffffffffffffff
print(a & (1 << 80))
print((a & (1 << 80)) >> 80)
print((a & (1 << 80)) >> 80 == 1)
# test negative on rhs
a = 123456789012345678901234567890
print(a & -1)
print(a & -2)
print(a & -2345678901234567890123456789)
print(a & (-a))
# test negative on lhs
a = 123456789012345678901234567890
print(-1 & a)
print(-2 & a)
print(-2345678901234567890123456789 & a)
print((-a) & a)
print((-a) & 0xffffffff)
print((-a) & 0xffffffffffffffffffffffffffffffff)