# HEX-BIN.DOC

``` BBS: Inland Empire Archive
Date: 03-27-93 (19:40)             Number: 355
From: EARL MONTGOMERY              Refer#: NONE
To: ALL                           Recvd: NO
Subj: HEX-BIN.DOC                    Conf: (2) Quik_Bas```
```Part I of II
8<------8<--------8<-------8<----  Snip

While refreshing my memory on Hexadecimal and Binary notations
(and the use of the logical operators <AND> <OR>, I found that
it helped to take notes. This is a compilation of those notes.
Some phrasing is entirely my own. So if you find any mistakes
(other than grammar, sentence structure, or spelling! <smile>)
please inform me so I can correct my document file. This
document should prove useful to the new programmers.

A little info on Hexadecimal notation.

Hexadecimal is a numbering system based on 16 elements.
Digits are numbered 0 through F as follows:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Representing the digits 0 through 15.

Hexadecimal system uses powers of 16. For example:
&H19 (hexadecimal) represents 25 decimal. Let's see why.
Starting from the right the power is 1. Therefore 9 X 1 = 9
Moving left the next is power is 16. Therefore 1 X 16 = 16
And 9 + 16 = 25.

Let's try another. This time &HFF (hexadecimal)
Again starting from the right (F=15) 15 X 1= 15
Moving left 15 X 16 = 240.
And 240 + 15 = 255

So far we have looked at single byte hex values. Let's look at
a 16 bit hex value. Remember 8 bits to the byte? Now we look at
two adjoining bytes, or sixteen bits.

Again starting from the right 2 X 1= 2
Moving left 0 X 16 = 0
Moving left again <16 X 16 =256> 9 X 256 = 2304
Moving left again <16 X 256 = 4096> 1 X 4096 = 4096
And 2 + 0 + 2304 + 4096 = 6402

In basic hex values are preceeded by &H. For example &HFF or &H1902
In basic hex values can be determined by the command PRINT &HFF
or PRINT &H1902.

Decimal to hex is accomplished by PRINT HEX\$(255)
or PRINT HEX\$(1902).

Now let's look at the individual bits within a byte.

Remember there are 8 bits to the byte and reading from Right
to Left they increase in power by the power of 2.

Binary notation reflects set bits with a 1. Non set bits with a 0.
Let's look at one.

1 0 0 0 1 0 0 1 (This byte represents 137)
As with hex we start at the right.

1 X 1= 1
Moving left 2 X 0 = 0
Moving left again 4 X 0 = 0

>>>>>>> Continued on next message >>>>>>>

--- Maximus 2.01wb
* Origin: Rabbit and Snake's BBS - Richardson, Texas (1:124/6108)
``` Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET