Is it me or is it insanity that "C" doesn't support BINARY???
Using "Binary" in "C"
-
StepFather
- Baa!

- Posts: 47
- Joined: Sun Oct 30, 2005 5:57 pm 0
- Location: SPACE
Using "Binary" in "C"
Cheers,
Is it me or is it insanity that "C" doesn't support BINARY???
I mean you can print decimal numbers using %d, octal using %o and Hex using %x, where the heck is BINARY??? 
Is it me or is it insanity that "C" doesn't support BINARY???
-
StepFather
- Baa!

- Posts: 47
- Joined: Sun Oct 30, 2005 5:57 pm 0
- Location: SPACE
-
StepFather
- Baa!

- Posts: 47
- Joined: Sun Oct 30, 2005 5:57 pm 0
- Location: SPACE
I agree all the way; Assembly is better than anything I have ever done. But landing a games industry job today with Assembly skills alone is worthless. You are EXPECTED to know at least C and in 99% of all cases also C++ and be an expert in Design Patterns.wossname wrote:This only serves to prove that C is a load of crap and always has been. ASM is the master and always will be![]()
![]()
DWORD cheapRestaurant 10111010101011011111000000001101b
-
StepFather
- Baa!

- Posts: 47
- Joined: Sun Oct 30, 2005 5:57 pm 0
- Location: SPACE
- pogo
- Sheepie Whore

- Posts: 14180
- Joined: Tue Sep 10, 2002 8:28 pm 0
- Yahoo Messenger: BrassSparrow
- Location: County Durham
As everyone's used to using hex ? There's nothing to stop language vendors adding it - all compilers I use have vendor specific extensions, to deal with things not covered in the language spec, and add preprocessor and platform-specific capabilities. No-one's added binary that I know of so there can't be much call for it.Firefox wrote:I must admit that I am a little puzzled that they didn't fix this in C99.
-
StepFather
- Baa!

- Posts: 47
- Joined: Sun Oct 30, 2005 5:57 pm 0
- Location: SPACE
@Pogopogo wrote:As everyone's used to using hex ? There's nothing to stop language vendors adding it - all compilers I use have vendor specific extensions, to deal with things not covered in the language spec, and add preprocessor and platform-specific capabilities. No-one's added binary that I know of so there can't be much call for it.Firefox wrote:I must admit that I am a little puzzled that they didn't fix this in C99.
What compilers do you use?
some precompilers include 0b..... as an directive for binary constants (I can't remember which, off the top of my head, but I've definitely seen it) and there are some versions of atol/ltoa et al that deal with binary too.pogo wrote:all compilers I use have vendor specific extensions, to deal with things not covered in the language spec, and add preprocessor and platform-specific capabilities. No-one's added binary that I know of so there can't be much call for it.
I have to say, though, that in 20+ years of programming C and related languages, I have never once needed to use binary. And the only time I've come across the 0b prefixed constants was when I had to fix code on a compiler change. Sure, it looks like an logical thing, C can deal with hex, decimal and octal, but in reality you simply don't need it 99.999% of the time, which is probably why C99 doesn't include a fix..
The only possible use I can think of is monitoring memory addresses for bit-level changes, and for that, if you want to dump out a byte / word / whatever in binary representation, it's a very simple macro, after all.
Simon
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
Binary constants could be useful for doing bit mask enumerations, but I just tend to do (1 << x) where x is the bit number.
The reason asm is not required for games coding these days is that every machine has a different one now, and I really don't think most people want to be coding x360 or ps3 entirely in assembler. If you can do asm, it's still a sought after skill (always room for optimising) but it's no longer a core skill requirement.
Digressing further, the currently in vogue skill for new entrants to the industry is skill in concurrent programming. Can't think why
The reason asm is not required for games coding these days is that every machine has a different one now, and I really don't think most people want to be coding x360 or ps3 entirely in assembler. If you can do asm, it's still a sought after skill (always room for optimising) but it's no longer a core skill requirement.
Digressing further, the currently in vogue skill for new entrants to the industry is skill in concurrent programming. Can't think why
It would be of use to me in my admittedly niche system-on-chip programming exploits.
Such chips have literally hundreds of registers which each contain a dozen or more packed bitfields, so it'd be really nice to go "*xyzreg = (0b110 << 27) | (0b01110 << 23) | (0b11 << 15)..." or similar (though probably something a bit more self-documenting than that).
Instead I ended up writing a specialist calculator that could translate back and forth between the separate bitfields and the equivalent hex constant.
Oddly enough the GNU assembler supports the "0b" prefix (as well as the familar "0" for octal and "0x" for hex) but the GNU C compiler doesn't.
Such chips have literally hundreds of registers which each contain a dozen or more packed bitfields, so it'd be really nice to go "*xyzreg = (0b110 << 27) | (0b01110 << 23) | (0b11 << 15)..." or similar (though probably something a bit more self-documenting than that).
Instead I ended up writing a specialist calculator that could translate back and forth between the separate bitfields and the equivalent hex constant.
Oddly enough the GNU assembler supports the "0b" prefix (as well as the familar "0" for octal and "0x" for hex) but the GNU C compiler doesn't.
- pogo
- Sheepie Whore

- Posts: 14180
- Joined: Tue Sep 10, 2002 8:28 pm 0
- Yahoo Messenger: BrassSparrow
- Location: County Durham
I think a good understanding of asm is still valuable, but not for coding in it. It's useful for debugging - sometimes it's only possible to step through code in (dis)assembly mode instead of source mode, e.g. when much of the code you're interested in has been inlined.Flabio wrote:The reason asm is not required for games coding these days is that every machine has a different one now, and I really don't think most people want to be coding x360 or ps3 entirely in assembler. If you can do asm, it's still a sought after skill (always room for optimising) but it's no longer a core skill requirement.
But it's even more important to know enough asm to avoid writing C code which runs inefficiently on a particular platform. You can learn a lot about what works well and what doesn't by just stepping through the compiled output of your code in the debugger (and often spot programmers who don't know assembler from their C code).
Anyway, back on topic, I have no problems dealing with bitfields and similar objects in hex most of the time. For 32 and 64 bit registers hex is much easier than parsing 32 or 64 zeros and ones. In code I'll use stuff like
Code: Select all
enum {bit1, bit2, bit3, bit4, bit5};
enum {mask1 = 1 << bit1, mask2 = 1 << bit2, ..., maskAll = mask1 | mask2 | ...};MS VCC, GCC (on the Mac and for consoles) mostly, Metrowerks C occasionally.StepFather wrote:@Pogo
What compilers do you use?
-
StepFather
- Baa!

- Posts: 47
- Joined: Sun Oct 30, 2005 5:57 pm 0
- Location: SPACE
MS VCC, GCC (on the Mac and for consoles) mostly, Metrowerks C occasionally.[/quote]StepFather wrote:@Pogo
What compilers do you use?
@Pogo,
Thanx

