# Number Bases

Number Bases are different methods of displaying the same numerical value. It's good to know these three common bases: decimal for regular numeration, binary for imagery, and hexadecimal for addressing. Each of these groups represents a different number to the processor. In a set of machine code, each group represents a different command for the processor to carry out. In asm language coding, you have to learn how to think like the computer. You have to be able to use binary and decimal number bases along with hexadecimal, so you must learn the concept of changing between these number bases.45 = %00101101 = $2d = %00101101 = 45While you're browsing through, try using a Converter to test what you're reading. If you experiment as you go along, you'll learn the concepts better.

## Decimal

Decimal numbers are a base ten. It's base ten because there are ten different symbols used:`0,1,2,3...9`

. We
use decimal for almost everything, so I'm not going to
explain how to write a number in that form.
## Binary

You probably have heard of binary numbers before, meaning numbers represented by a series of ones and zeros:3=%00000011Computers don't use numbers in the form of 2, 3, 9, 134, or 6 to do their math. Instead, they use groups of

`1`

's
and `0`

's.
%00010101 %01110100 %01101110 %01101111Binary is just a group of eight ones and zeros with a base two. It's base two because there are only two symbols used:

`0`

and `1`

. If you have a binary
number, you have to look at the whole thing starting from
the right side. Binary numbers are shown with a `%`

before
them or a `b`

; after
the number. I will reference them with a `%`

; in the
rest of this document. A number without any symbol before or
after it means that it is in decimal form.
Let's work with the following number:
%00100011 = 35A

`1`

in a certain spot symbolizes a certain value. A
`0`

means no "no value here". The following chart shows how much a
one is worth in each spot:
Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

0=%00000000 |

1=%00000001 |

2=%00000010 |

3=%00000011 |

4=%00000100 |

5=%00000101 |

6=%00000110 |

7=%00000111 |

8=%00001000 |

9=%00001001 |

10=%00001010 |

`%00100011`

you have a one in the
bit 0 place, so we add `1`

to the total, which is zero
since we just started. We have another one in the bit 1 place, so we add
`2`

to the total bringing the total to `3`

.
The next three bit places (bits 2 through bit 4) all have `0`

's
in them so we skip them. Our last `1`

is in the bit 5 place
which is worth `32`

, so we add `32`

to the total
so far and we have `35`

. So, `%00100011 = 35`

.
The maximum value a byte can have is `255`

.
Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 | ||

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | ||

12 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | %00001100 |

44 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | %00101100 |

75 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | %01001011 |

00 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | %00000000 |

128 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | %10000000 |

255 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | %11111111 |

3 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | %00000011 |

4 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | %00000100 |

58 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | %00111010 |

69 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | %01000101 |

200 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | %11001000 |

Name | Size | Visual |

Bit | A single 1 or 0 | 0 |

Nibble | Four bits | 0000 |

Byte | 8 Bits | 00000000 |

Word | Two bytes | 00000000 00000000 |

Long Word | Four bytes | 00000000 00000000 00000000 00000000 |

## Hexadecimal

Hexadecimal is our next number base used. This is on a base sixteen because there are sixteen different symbols we can use:`0,1,2,3,...9, A, B, C, D, E,`

and `F`

.
A `$`

before a number, or a `h`

after the number, denotes
that it is in hexadecimal form. The following chart is the best
way to learn the relationship between these numbers:
Dec | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |

Hex | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f | 10 | 11 |

`35`

again,
the hexadecimal representation of that would be `$23`

in hexadecimal.
Dec | Hex |

1 | $1 |

23 | $17 |

52 | $34 |

12 | $0c |

255 | $ff |

128 | $80 |

69 | $45 |

95 | $5f |

74 | $4a |

111 | $6f |

## Conversions

You can practice converting numbers with simple scripts such as the Converter or you can use your TI86's Base Conversion menu by pressing the following keys: [2nd] [1]. Then you have the option of choosing any one of the following:- [F1] will give you a menu filled with the letters used in hexadecimal representation.
- [F2] will give you the symbols used to denote which base a number is in so the TI86 can understand it.
- [F3] gives you the conversion commands.
- [F4] brings up the Boolean Items discussed in the Logical Operators section.
- [F5] loads the bit manipulation routines discussed in the Shift and Rotate section.

`$`

before a number or a
`h`

after the number denotes that it's in
hexadecimal form, a `%`

before a number or a
`b`

after the number denotes that it's in binary
form, and when there's just a number without those symbols
it's just in plain old decimal form.

**More from z80 » Beginner**

Aliases // Convert from decimal to hexadecimal or binary // Flags and Conditions // Format and Compiling // Instructions // Math // Number Bases // Oh, No! It Crashed! // Registers // TI-BASIC to Asm Comparisons // TI86 Specifications // Two's Compliment // z80 Processor