How do you write binary literal constants in C?
In C, to write a hexadecimal literal constant, you prefix the figure with 0x, e.g. 0xffe0119f. To write an octal literal, you prefix it with 0, e.g. 0777. So how do you write a literal in binary?
|
ansi c does not support binary constants, you'll have to write your numbers in hex, octal or decimal
|
What a bummer!
|
if its a real big problem then write something with sed/tr/perl that replaces 0b(binary number) with 0x(hex equivelent) in your source file and write a makefile that runs this before compiling the source. but as you can convert bin/hex bin/octal by inspection its not really worth it.
|
Converting from binary to hex is really easy, though. Groups of four binary digits represent one hex digit. Probably the reason that binary literals aren't included; Real C Programmers know how to think in Hex anyway ;)
Check out this for more explanation. |
Quote:
Has my licence to hack been revoked? |
All times are GMT -5. The time now is 01:35 AM. |