Binary Magick

Index

Welcome to Binary Magick. The site is still under some construction, though as a Steganography site relies on the use of some of these binary techniques I thought I would publish the basic ones quickly.

Divide by two (x // 2) Rounded Down - [ >> 1 ]

Bitshift right 1.

10 >> 1
5

11 >> 1
5

Multiply by two (x * 2) - [ << 1 ]

Bitshift left 1

6 << 1
12

12 << 1
24

Is odd (x % 2 != 0) - [ & 1 ]

And 1

Zero (0) is False and One (1) is True.

10 & 1
0

11 & 1
1

Add to nearest odd ( ((x // 2) * 2) + 1 ) - [ | 1]

Or 1

10 | 1
11

11 | 1
11

14 | 1
15

5 | 1
5

Function, inverse function ( ƒ (xy) = ƒ-1 (xy) ) - [ x ^ y ^ x = y ]

Xor, exclusive or, either or but not both.

10 ^ 20
30

10 ^ 30
20

20 ^ 30
10