Acorn BBC Micro Logo displayed on Famicom picture
20F07 — Acorn BBC Micro Logo displayed on Famicom

Binary numbers are a base 2 numeral system.

Basics

Hexadecimal to Binary Conversion

000004010081000C1100
100015010191001D1101
2001060110A1010E1110
3001170111B1011F1111

Arithmetic

Addition

inputADDoutputcarry
0110
0000
1101
1010

Subtraction

inputSUBoutputborrow
0111
0000
1100
1010

Multiplication

inputMULoutput
010
000
111
100

Bit Masks

AND, or "both", sets individual bits to 0. AND is useful for masking bits, for example, to mask the high order bits of a value AND with $0F: $36 AND $0F = $06.

inputANDoutput
011
000
110
101

ORA(OR), or "either one or both", sets individual bits to 1. OR is useful for setting a particular bit, for example, $80 OR $08 = $88

inputORAoutput
011
000
111
101

EOR(XOR), or "one or the other but not both", inverts individual bits.

inputEORoutput
011
000
110
101

Signed Integers

If Bit 7 is not set (as in the first example) the representation of signed and unsigned numbers is the same. However, when Bit 7 is set, the number is always negative. For this reason Bit 7 is sometimes called the sign bit.

BinaryUnsignedSigned
0010 00113535
1010 0011163-93
1111 1111255-1
1000 0000128-128