numbers.

Recall that I've mentioned a counting program which displays numbers from 1

to 10. You may also recall that i wrote two versions of this program - first

initializing "i" to zero then reinitializing "i" to one, and I said I'll

come back to a more detailed discussion on it. The reason why I brought this

up is because computers use zero-based indexing (counting from zero up) when

dealing with almost everything - from storage size to counting, unlike us

using one-based indexing. This becomes important as we tackle arrays (a

group of same data type) - arrays and such start counting their index at

zero, not one. So the first data in an array is indexed zero, then one, two,

etc. as opposed to how we would count it - first, second, etc.

As for storage sizes: there are many prefixes that computers and users use

to identify the size of something. To start with, a byte (a character) is

eight bits (binary digit). Also, people use ten-based counting (decimal)

when talking about size, whereas computers use two-based counting (binary).

So, a kilobyte, or about 1000 characters, would be a thousand characters

when spoken by users. Computers, on the other hand, treats a kilobyte (KB)

as 1024 bytes (2 to the 10th power).

Here are some prefixes when talking about different size of things:

* A byte: eight bits.

* Kilobyte (KB): 1000 characters versus 1024 bytes.

* megabyte (MB): 1 million characters versus 1048576 bytes (2^20).

* Gigabyte (GB): 1 billion characters versus 1073741824 bytes (2^30).

* Terabyte (TB): 1 trillion characters versus about 1.099*10^12 (2^40).

As you can see, the differences become pronounced as size increases.

One last thing: there are more number bases besides decimal (base 10). In

fact, we can count anything using any number base. Some of the well known

ones include decimal, binary (base 2), octal (base 8) and hexadecimal (base

16). For example, the number 10 can be represented in other bases such as

1010 (binary), 12 (octal) and A (hexadecimal). Note: the decimal values from

10 to 15 under hexadecimal are represented by A through F.

Another example: suppose if we want to convert a hexadecimal value 3D to

other bases. The answer would be: 61 (decimal), 75 (octle) and 111101

(binary).

I guess that sums up hardware basics. Now, let's return to software

basics...

// JL

## No comments:

## Post a Comment