Professional Documents
Culture Documents
Binary Fund
Binary Fund
{
s
−~x = x + 1 ~x ^ y sign s value = ( −1) 2 e−15 1 + sign s
~x ~(x ^ y) = 210
~−x = x − 1 x ^ ~y
Double precision s m
value = ( −1) 2 e−1023 1 +
64-bit floating-point 252
Binary Logical Operations 11 bits 52 bits
exponent e mantissa m
AND OR
x y x & y x y x | y sign s
0 0 0 0 0 0
0 1 0 0 1 1
Bitwise AND Bitwise OR Special Floating-Point Value Half Float Double
1 0 0 1 0 1
x & y 1 1 1 x | y 1 1 1 +0.0 0x0000 0x00000000 0x00000000_00000000
+1.0 0x3C00 0x3F800000 0x3FF00000_00000000
NAND NOR
x y ~(x & y) x y ~(x | y) Positive infinity 0x7C00 0x7F800000 0x7FF00000_00000000
0 0 1 0 0 1
Smallest positive normalized value 0x0400 0x00800000 0x00100000_00000000
0 1 1 0 1 0
Not AND Not OR Upper limit of non-integer values 0x6400 0x4B000000 0x43300000_00000000
1 0 1 1 0 0
~(x & y) 1 1 0 ~(x | y) 1 1 0 Largest representable positive value 0x7BFF 0x7F7FFFFF 0x7FEFFFFF_FFFFFFFF
ANDC ORC
x y x & ~y x y x | ~y
0 0 0 0 0 1 Mask Creation
0 1 0 0 1 0
AND with complement OR with complement Formula Operation / Effect Illustration
1 0 1 1 0 1
x & ~y 1 1 0 x | ~y 1 1 1 Create mask for all bits other than lowest 1 bit. 1 0 1 1 1 0 0 0
~x | (x − 1)
000⋯000 becomes 111⋯111.
1 1 1 1 0 1 1 1
XOR XNOR
x y x ^ y x y ~(x ^ y)
Create mask for all bits other than lowest 0 bit. 0 1 1 0 0 1 1 1
0 0 0 0 0 1
x | ~(x + 1)
0 1 1 0 1 0 111⋯111 is unchanged.
1 1 1 1 0 1 1 1
Exclusive OR Exclusive NOR
1 0 1 1 0 0
x ^ y 1 1 0 ~(x ^ y) 1 1 1 Create mask for bits left of lowest 1 bit, inclusive. 1 0 1 1 1 0 0 0
x | −x
000⋯000 is unchanged.
1 1 1 1 1 0 0 0
1 0 1 1 1 0 0 0
Bit Manipulation x ^ −x
Create mask for bits left of lowest 1 bit, exclusive.
000⋯000 is unchanged.
Formula Operation / Effect Illustration 1 1 1 1 0 0 0 0
Set lowest 0 bit. 0 1 1 0 0 1 1 1 Create mask for bits left of lowest 0 bit, exclusive. 0 1 1 0 0 1 1 1
x | (x + 1) ~x ^ (x + 1)
111⋯111 is unchanged. 111⋯111 becomes 000⋯000.
0 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0
Set all bits to right of lowest 1 bit. 1 0 1 1 1 0 0 0 Create mask for bits right of lowest 1 bit, inclusive. 1 0 1 1 1 0 0 0
x | (x − 1) x ^ (x − 1)
000⋯000 becomes 111⋯111. 000⋯000 becomes 111⋯111.
1 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1
Extract lowest 1 bit. 1 0 1 1 1 0 0 0 Create mask for bits right of lowest 0 bit, inclusive. 0 1 1 0 0 1 1 1
x & −x x ^ (x + 1)
000⋯000 is unchanged. 111⋯111 is unchanged.
0 0 0 0 1 0 0 0 0 0 0 0 1 1 1 1
Extract lowest 0 bit (as a 1 bit). 0 1 1 0 0 1 1 1 Create mask for bits right of lowest 0 bit, exclusive. 0 1 1 0 0 1 1 1
~x & (x + 1) x & (~x − 1)
111⋯111 becomes 000⋯000. 111⋯111 is unchanged.
0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1
By Eric Lengyel
Copyright © 2023