binary constants (??)

Walter Bright bright at Data-IO.COM
Tue Nov 21 06:22:46 AEST 1989


In article <305 at frf.omron.co.jp> jfriedl at frf.omron.co.jp (Jfriedl) writes:
<In some cases, I find it would be much more natural to represent
<integral constants in binary.

I agree (as I create bit patterns for icons for graphics). In fact,
Datalight C and Zortech C/C++ have always supported binary constants:

	int x = 0x16;		/* 22	*/
	int o = 026;		/* 22	*/
	int b = 0b10110;	/* 22	*/

printf() and scanf() support it also (with the %b format specifier).
If you have the source to gcc, I suspect that the modifications to the
lexical analyzer are trivial.

P.S. ANSI C rejected my suggestion for this! Even though there is 'prior art'.



More information about the Comp.lang.c mailing list