 |
 |
Basic ?: Binary Digits in C/C++
|
 |
|
 |
|
Junior Member
Join Date: Oct 2001
Location: Los Angeles
Status:
Offline
|
|
I pose a simple question: Is there a way to code binary digits into a program rather than typical decimal.
I know this is possible with hex and oct, but I can't find any information about binary.
I want something like this: 0xA only for binary-- not hex.
I thought this should be something easy to do, but I can't find mention of such a feature in any of my books. I thought I would try you guys out.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jun 2000
Location: Eastern Washington (St. John/Cheney)
Status:
Offline
|
|
Originally posted by Arakageeta256:
<STRONG>I pose a simple question: Is there a way to code binary digits into a program rather than typical decimal.
I know this is possible with hex and oct, but I can't find any information about binary.
I want something like this: 0xA only for binary-- not hex.
I thought this should be something easy to do, but I can't find mention of such a feature in any of my books. I thought I would try you guys out.</STRONG>
Woah...I could have sworn there is a way to do this in C++. But after checking my reference manual, I can't find any mention of this. I though it was something like this
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>int foo = 010101010b;</font>[/code]
Note the 'b' at the end. Strange. Just tested it in Project Builder and it didn't work. Guess it's not possible to do that. Apparently nobody uses binary anymore :-)
CyberDave
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
!
Same here, I knew it was either 0b1010101010 or 1010101010b.
But it seems to have disappeared (won't compile). I *know* I used binary constants before...
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
Come to think of it, the last time I used binary constants was in VirtualPC using TIGCC (compiler for TI calculators) for coding sprites. I'm not sure if I ever used it on cc.
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Oct 2000
Location: Portland, OR USA
Status:
Offline
|
|
There is no language construct for binary in C/C++ (it would be 0b01010101 if there was). However, hex is very suitable to any thing you'd want to cade as binary since hex is really just shorthand for binary. I use hex all the time for bit masking.
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Oct 2001
Location: Los Angeles
Status:
Offline
|
|
C/C++ supports almost every assbackward way of doing things. It's amazing that this isn't. Oh well, I guess hex will do fine.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|