![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
What does the "0x" in "0x2F" mean? I get that the "2F" is hexadecimal, but what relevance does the "0x" have?
| |
| |
| | #2 |
|
0x means a hexadecimal number follows
| |
| |
| | #3 |
|
It is used to distinguish between 'AF' the alphabetic string and 0xAF the hexidecimal number. The number starts with a digit which has the same value in any number base.
__________________ We never have time to do it right; but we always have time to do it over. | |
| |
| | #4 |
|
and 0b will often proceed binary numbers, just FYI
Last edited by Triode; 25th June 2009 at 11:39 PM. | |
| |
| | #5 |
|
Hi, In that little code example I sent you will see on the first line the code LIST P=18F2550,r=hex - radix=hex - meaning that any uncoded number will be treated as a hex value - so if you had movlw 16 it would be recognised as hex 0x16. It is also quite popular for the radix=dec when 16 is simply that, but more commonly coded as .16 - the full point denoting a decimal value follows. Even when using the Radix statement, to avoid problems its perhaps wise to always code your values accordingly 0xhex or .dec or binary b'01010101' | |
| |
| | #6 |
| As many have said, the 0x (in many languages including C and PIC ASM) is a prefix added to hexadecimal numbers. 0b means binary and 0d usually designates decimal, although decimal is usually default and assumed to be decimal without any prefix. 0O (zero-oh) usually means octal :P
| |
| |
| | #7 |
|
thanks a lot | |
| |
| | #8 |
| If you read the MPASM/MPLAB help files, all these things are explained.
| |
| |
| | #9 | |
| Quote:
| ||
| |
| | #10 |
|
If you want to figure out the binary/hexadecimal thing use this chart I created. I constantly use it when I'm writing code for PICs. It helps me speed up the coding after I create a chart of how I want ports to be either High or Low. ![]() heres a little bit of sample code Code: movlw 0x0A movwf PortB
__________________ This is the way the world ends, This is the way the world ends, This is the way the world ends, Not with a BANG But with a BELCH BURRRRRRRRRRPPPPPPP Last edited by skeeterb; 26th June 2009 at 03:10 PM. | |
| |
| | #11 |
|
Doesn't the Windows Calculator provide a simple mechanism for looking at a number as decimal, binary, or hex?
| |
| |
| | #12 |
|
I wanted a quick reference guide I can use when I'm coding. All I have to do is do a search in my hex/binary chart and go straight to the correct hex code
__________________ This is the way the world ends, This is the way the world ends, This is the way the world ends, Not with a BANG But with a BELCH BURRRRRRRRRRPPPPPPP | |
| |
| | #13 | |
| Quote:
"HexCon" Hex-Decimal-Binary converter | ||
| |
| | #14 | |
| Quote:
The time it takes to learn the 16/32 conversion will be paid back to you many times.
__________________ Please post questions to the forums. PM's are for personal communication. BCHS/3v0's Tutorials Junebug USB PIC programmer kit., USB Bit Whacker, The 15 Minute Printed Circuit Board! (+drill time) | ||
| |
| | #15 |
|
I'm just not sure why you made the chart go up to 2 digits of hex and 8 of binary. Hex converts in nice 4 bit chunks, thats why its used with computers. You can look at any hex digit and know what the corresponding block of 4 binary bits ("nibble") is without knowing the digits that proceed it. Conversly, if I tell you "I have a decimal number, the fifth digit is 9" you can't get the corresponding binary for that part of the number.
Last edited by Triode; 26th June 2009 at 06:42 PM. | |
| |
|
| Tags |
| 0x2f |
| Thread Tools | |
| Display Modes | |
| |