home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-03 | 5.6 KB | 110 lines | [TEXT/ttxt] |
- Numbering Systems Version: 1.0 Nov 1995
- Author: Jesse Carneiro
- Micro Fox Software
- Address: P.O. Box 14932 / Columbus, Ohio 43214-0932 / U.S.A.
- Internet: microfox@kagi.com
- Web Page: http://www.infinet.com/~microfox
- Shareware: Send a postcard of your town, if you use it.
-
- The application Numbering Systems serves as a little utility for
- converting Decimal into Hexadecimal and Binary systems and vice
- versa.
-
- It shows the relationship of numbers in different systems. If you
- enter a decimal number and press the Enter or Return key, it will
- show on the Hexadecimal and Binary fields the representation of the
- entered number in those systems. Now if you press the Up or Down
- arrow keys, you’ll add or subtract one to that number and see its
- progression on the other fields. Notice how they change as you keep
- adding. Observe specially when you change from decimal 255 to 256.
-
- Representing Numbers
- We grew up quite familiar with the decimal numbering system. It
- seems so simple and quite adequate for what we need. However, when
- you start to learn programming, soon you’ll encounter other systems.
- At first these other numbering systems seem hard to understand (at
- least it seemed to me). But soon, you’ll understand the reason for
- their use.
-
- Computers, in general, use memory in which every byte (eight
- consecutive bits of zeros or ones) has a number associated with it.
- This number associated with every byte is said to be the address of
- that byte. A way to get to it. It starts at zero and move on up to
- however many megabytes of memory the user has installed on his
- machine. Pretty soon, using the decimal system, we would need many
- digits just to represent most of these bytes. If they are after the
- million byte mark, we will need six digits, etc., but using the
- hexadecimal numbering system, we could refer to these bytes with
- only a few digits, which is more convenient for programmers. On the
- other hand, sometimes a single byte (composed of 8 bits) could have
- some of its bits represent “flags," that is, the state of something
- (usually something that can be "ON" or "OFF" — often referred to as
- that bit being set [1] or not being set [0]).
-
- However, as the accompanying program, Numbering Systems, will show
- you, turning bits ON (changing them from zero to one) on a byte,
- will accommodate numbers only up to 255*. As such, the number 255
- represent all 8 bits being set to one. Add one more 1 to it and you
- will need another byte to represent it. Now we have a lot more bits
- to set. But soon you will run into a number limit when again, all of
- its bits are set to one. That number is 65535 in decimal, FFFF in
- hexadecimal or 1111 1111 1111 1111 in the binary system (Please
- Note: I am only referring to unsigned numbers, i.e., whole positive
- numbers). It represents the maximum number that can fit on two bytes.
- To represent larger numbers you need more bytes. It is obvious by
- now that the more bits (or bytes, if you group them) that you have
- to represent a number, the larger the number can be.
-
- Just like we group letters together to form words and then group
- words together to form sentences, and then group these to form
- paragraphs, etc., in computer programming we group 8 bits together
- and call it a Byte. We group two bytes and call it an Integer. We
- group four bytes and call it a Long Integer, group a mixture of
- these and you can call it a struct (in C) or a Record (in Pascal).
- In the programming languages Pascal, C, etc. that is the norm, but
- note that on some programming languages, an integer and a long
- integer may both have four bytes. They are used to accommodate
- numbers that can be fit within their limits.
-
- Addresses
- On the Macintosh, as with other computers, by virtue of its hardware
- design, the address of the bytes in memory is given 32 bits (4 bytes)
- for the representation of this address number. As such, you can fit
- a number as larger as decimal 4,294,967,296 (over four billion),
- FFFFFFFF in hexadecimal or 32 ones in binary. That would be the
- maximum number of bytes that such computer could access. It is an
- amazingly high number. Can you imagine 4 gigabytes of RAM memory?
-
- Just remember that all of this is only different ways to represent
- numbers. Decimal numbers makes more sense to us. Hexadecimal is very
- handy when working with a programming language. And zeros and ones
- is only what the CPU of a computer understands anyway. But they all
- represent the same thing: a number.
-
- I hope this helps a bit (no pun intended).
-
- Jesse Carneiro
- Micro Fox Software
- P.O. Box 14932
- Columbus, OH 43214-0932
- U.S.A.
- Phone or Fax (614) 267-8638
- Internet: microfox@kagi.com (support, comments, etc.)
- Web Page: http://www.infinet.com/~microfox
-
-
- *PS - The program Numbering Systems only deals with positive numbers
- that can fit on an integer (two bytes). In reality, a byte can
- accommodate negative numbers also. The difference being that
- instead of the range being 0 to 255 as is on an unsigned integer,
- the range becomes –127 to +128 on a signed integer. The same
- treatment is given to signed long integer.
-
-
- ©1995 Jesse Carneiro
- The usual disclaimers apply: Jesse Carneiro and Micro Fox Software
- accept no responsibility for any incidental or consequential damage
- of any sort as a direct or indirect result of using this software.
- The software is provided “as-is,” and no warranties are made as to
- its fitness for a particular purpose. I would be very interested to
- hear of any problems, though.