NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Basic Electronics » HELP
June 04, 2012 by mikeduff76 |
OK i want to know if i can use binary numbers in a code |
---|---|
June 04, 2012 by hevans (NerdKits Staff) |
Hi mikeduff76, I think you are asking if you can write binary literals into your C code. The answer is no, the C language does not have a way of writing binary literals, however you can write hex literals by prefixing them with 0x. Once you get used to it, its pretty easy to convert between the hex and binary representations of a number. Humberto |
June 04, 2012 by pcbolt |
mike - Some compilers may let you get away with using this format:
I've gotten errors using this with "cl.exe" but not with "gcc" in MinGW. I have not tested it with "avr-gcc". |
June 05, 2012 by Rick_S |
The 0b prefix works fine. I have used it before. Sometimes it makes the logic a bit easier to "see". Rick |
June 05, 2012 by mikeduff76 |
ok well i am actully using it for a airplane with the power source from the nerd kit so it dosent afect my nerd kit |
June 11, 2012 by mikeduff76 |
hi |
Please log in to post a reply.
Did you know that a thermometer can be made "faster" by using a bit of math? Learn more...
|