Is self a power of two ?

assert not 3.is_pow2
assert 2.is_pow2
assert 1.is_pow2
assert not 0.is_pow2

Property definitions

core :: math $ Int :: is_pow2
	# Is `self` a power of two ?
	#
	# ~~~nit
	# assert not 3.is_pow2
	# assert 2.is_pow2
	# assert 1.is_pow2
	# assert not 0.is_pow2
	# ~~~
	fun is_pow2: Bool do return self != 0 and (self & self - 1) == 0
lib/core/math.nit:173,2--181,65