maths/boolean
This module contains code to do boolean logic on integers. Boolean logic here is the special case of arithmetic circuit logic with p = 2.
Functions
Performs a logical AND
operation on two integer values.
Expects both inputs as binary (0 or 1) and returns 1 if both are 1, otherwise returns 0.
boolean.and_(1, 1)
Performs a logical OR
operation on two integer values.
Expects both inputs as binary (0 or 1) and returns 1 if at least one input is 1, otherwise returns 0.
boolean.or_(0, 1)
Performs a logical NOT
operation on an integer value.
Expects the input as binary (0 or 1) and returns the inverse (1 becomes 0, 0 becomes 1).
boolean.not_(1)
Performs a logical XOR
operation on two integer values.
Expects both inputs as binary (0 or 1) and returns 1 if the inputs are different, otherwise returns 0.
boolean.xor_(0, 1)
Performs a logical NAND
operation on two integer values.
Returns 1 if at least one input is 0, otherwise returns 0.
boolean.nand_(1, 1)
Performs a logical NOR
operation on two integer values.
Returns 1 if both inputs are 0, otherwise returns 0.
boolean.nor_(0, 0)
Performs a logical XNOR
operation on two integer values.
Returns 1 if the inputs are the same, otherwise returns 0.
boolean.xnor_(1, 1)