anonymous
Visitor
 Fresh Osdever
| Posts: 0 |   | Karma: 0
|
Re: how do i convert Decimal to binary? - 2005/07/07 14:48
Hexadecimal is often used as it is easier to convert from binary to hexadecimal. To explain it is best to look at some examples: Decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, 10, 11, 12, 13, 14 Binary: 0, 1, 10, 11, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, 10001, 10010, 10011, 10100 (I apologise if any of those are wrong I just wrote them down in a hurry)
The key thing with the binary and hexadecimal relationships is that you can break up each binary number into 4 digits and those 4 digits can be converted seperatly from the rest of the number. The best way to explain is though example. Hex: 1 Binary: 0001 Hex: f Binary: 1111 Hex: 1f (31 decimal) Binary: 0001 1111 (See how each hex digit corelates to 4 binary digits?)
There are quite a few converter scripts out there (for when you feel to lazy to convert everything yourself) a quick google found: http://www.tonymarston.net/php-mysql/converter.php
Also some scientific calculator programs (and calculators) will do the conversion by pressing a special builtin button. (best to know how it works rather than depend on a calculator, but if your converting lots of numbers at once it would be silly not to use a converter program)
Also in assembly often the assembler can convert numbers for you. (check the documentation for your compiler but often putting a 'h' or 'b' after a number will inform the assembler what number base you are using).
Hope this helps, say if you need any further help getting your head around different base systems.
Daniel
|