bitnot ( x -- y )
Factor documentation > Factor handbook > The language > Numbers > Arithmetic > Bitwise arithmetic
Prev:bitxor ( x y -- z )
Next:shift ( x n -- y )


Vocabulary
math

Inputs and outputs
xan integer
yan integer


Word description
Computes the bitwise complement of the input; that is, each bit in the input number is flipped.

Notes
This word implements bitwise not, so applying it to booleans will throw an error. Boolean not is the not word.

Due to the two's complement representation of signed integers, the following two lines are equivalent:
bitnot neg 1 -


Definition
IN: math

GENERIC: bitnot ( x -- y ) foldable flushable


Methods
USING: math math.private ;

M: bignum bitnot bignum-bitnot ; inline


USING: math math.private ;

M: fixnum bitnot fixnum-bitnot ; inline