binary constants (??)

Matt Landau mlandau at bbn.com
Wed Nov 22 03:03:15 AEST 1989


On the subject of binary constants for creating cursor or image data,
here's a reposting of one of the more clever things I've seen come 
across comp.lang.c.  It's trivial to adapt this to use a syntax more
suited to traditional sets of flags, etc.

--
 Matt Landau			Oblivion gallops closer,
 mlandau at bbn.com		    favoring the spur, sparing the rein.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Article 5640 of comp.lang.c:
>From: ado at elsie.UUCP (Arthur David Olson)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: Binary integer literals
Date: 12 Dec 87 01:15:32 GMT

#include <stdio.h>

#define __	((((((((((((((((0
#define _	<<1|0)
#define X	<<1|1)

static unsigned short CursorPattern[16] = { 
	__	X X X X X X X X _ _ _ _ _ _ _ _ 	,
	__	X _ _ _ _ _ X _ _ _ _ _ _ _ _ _ 	,
	__	X _ _ _ _ X _ _ _ _ _ _ _ _ _ _ 	,
	__	X _ _ _ _ _ X _ _ _ _ _ _ _ _ _ 	,
	__	X _ _ _ _ _ _ X _ _ _ _ _ _ _ _ 	,
	__	X _ X _ _ _ _ _ X _ _ _ _ _ _ _ 	,
	__	X X _ X _ _ _ _ _ X _ _ _ _ _ _ 	,
	__	X _ _ _ X _ _ _ X _ _ _ _ _ _ _ 	,
	__	_ _ _ _ _ X _ X _ _ _ _ _ _ _ _ 	,
	__	_ _ _ _ _ _ X _ _ _ _ _ _ _ _ _ 	,
	__	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 	,
	__	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 	,
	__	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 	,
	__	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 	,
	__	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 	,
	__	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
};

main()
{
	int	i;

	for (i = 0; i < sizeof CursorPattern / sizeof CursorPattern[0]; ++i)
		(void) printf("%04x\n", CursorPattern[i]);
	return 0;
}



More information about the Comp.lang.c mailing list