Numbering systems ?
bennettdan
Posts: 614
Hello,
··· Does anyone have a an idea where I can find info on numbering systems and how to convert· Octal to Decimal to Hex·to Binary and so forth?
Post Edited (bennettdan) : 6/22/2006 1:56:41 AM GMT
··· Does anyone have a an idea where I can find info on numbering systems and how to convert· Octal to Decimal to Hex·to Binary and so forth?
Post Edited (bennettdan) : 6/22/2006 1:56:41 AM GMT
Comments
Any links to the info on the web?
bongo
In hex, it's (5 * 16^3) + (4 * 16^2) + (3 * 16^1) + (2 * 16^0) = 21554
In decimal, it's (5 * 10^3) + (4 * 10^2) + (3 * 10^1) + (2 * 10^0) = 5432
In octal, it's (5 * 8^3) + (4 * 8^2) + (3 * 8^1) + (2 * 8^0) = 2842
"16^3" means 16 to the third power
Any number to the zero power equals 1, so (x * y^0) = x
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
5432 (hex) = 0101_0100_0011_0010 = 0101010000110010
5432 (octal) = 101_100_011_010 = 101100011010
To convert decimal to hex, you have to divide the number by each power of 16 (ignoring the remainder), then subtract the value of that hex digit and continue. Luckily, division in PBASIC ignores the remainder automatically.
21554 (decimal):
21554 / (16^3) = 5
21554 - (5 * 16^3) = 1074
1074 / (16^2) = 4
1074 - (4 * 16^2) = 50
50 / (16^1) = 3
50 - (3 * 16^1) = 2
So 21554 decimal = 5432 hex
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
Try to understand what you need a certain format for.
I am not going to discuss 'floating point' as it is an advanced topic, more abstracted from the machine, and I am not good at it.
Binary is what the microprocessor uses and sees [noparse][[/noparse]But it is often hard to read when counting. It is good for showing exactly which port is high or low]
Hexadecimal is easier to read and easier to identify as not being decimal [noparse][[/noparse]because it has A,B,C....] It generally is used for counting and calculation of addresses in microprocessor.
Octal was used early on, but most people got it confused with decimal and now avoid it.
Binary Coded Decimal allows you to send, receive, and store two digits in ONE byte, but only numbers. IT is really prefered for clocks and calendars as months, days, years, hours, minutes, and second can all be stored as one byte each.
ASCII only allows one digit per byte, but you can mix it with the alphabet for text and some control characters.
Two's Compliment [noparse][[/noparse]made by taking one's compliment and adding a one] allows the microprocessor to have positive and negative digits that are easily manipulated. There are other systems of positive and negative besides this, but they are mostly history [noparse]/noparse]see [u]The Art of Electronics[/u.
Thusly, one begins to see four purposes. A. Ease of allowing the programmer to read B. Ease of compactly storing digits in some cases C. Clearly showing exactly what the bits are doing. D. some special display conversions
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
Post Edited (Kramer) : 6/22/2006 4:01:25 PM GMT
255 dec = FF hex because 15 * 16^1 + 15 * 16^0 = 240 + 15 = 255.
You can generalize the rule about working in different bases by remembering that in decimal, the right-most (least significant digit) has the weight of 1, the second digit from the decimal point has the weight 10, and so. As you go from right to left, the power of 10 increases. We're taught this in school so even though we aren't conscious of it, if we read the decimal number "123" we "know" that it has that value because we're doing this in our head:
123 = (10^2 x 1) + (10^1 x 2) + (10^0 x 3)
or
123 = 100 + 20 + 3
The same thing works for any base. Replace the 10's with 16's and you can see that the least-significant digit has the weight of 1 (every LSD is this way because the weight is always the base to the 0th power which is defined as 1), the next most significant digit has the weight 16, the next 256, and so on.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I wouldn't connect that if I were you...
For instance, Parallax uses one system and Microchip uses the other. I tend to know only Parallax's set up as I do most of my reading in their material. If you are only using 8bit, it is easier to guess, but now that 32bit is being used I sometimes find myself faltering.
This even goes into how the 'image files' are formated to download HEX data into an EEPROM. There again are two different formats that are historically divided along the loyalties to two major manufactures.
To really be versitle, you must go the extra distance and remember both sets of information. This is just the way the world works.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
bongo
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When you get 1st Place in the "Darwin Awards", you're a Winner & a Loser.