Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!super.upenn.edu!hyper.lap.upenn.edu!george From: george@hyper.lap.upenn.edu (George Zipperlen) Newsgroups: comp.lang.c,comp.lang.c++ Subject: Binary integer literals Message-ID: <2752@super.upenn.edu> Date: Tue, 8-Dec-87 18:17:14 EST Article-I.D.: super.2752 Posted: Tue Dec 8 18:17:14 1987 Date-Received: Sun, 13-Dec-87 14:48:56 EST Sender: news@super.upenn.edu Reply-To: george@hyper.lap.upenn.edu (George Zipperlen) Organization: University of Pennsylvania, Language Analysis Project Lines: 51 Keywords: binary, integer, literal Xref: mnetor comp.lang.c:5799 comp.lang.c++:628 Wanted: a way to declare binary constants! Arrays of binaries intended as bitmaps are much easier to read and edit than arrays of hex declarations. As an example here's a piece of C code: static unsigned short CursorPattern[16] = { 0xff00, /* 1111111100000000, */ 0x8200, /* 1000001000000000, */ 0x8400, /* 1000010000000000, */ 0x8200, /* 1000001000000000, */ 0x8100, /* 1000000100000000, */ 0xa080, /* 1010000010000000, */ 0xd040, /* 1101000001000000, */ 0x8880, /* 1000100010000000, */ 0x0500, /* 0000010100000000, */ 0x0200, /* 0000001000000000, */ 0x0000, /* 0000000000000000, */ 0x0000, /* 0000000000000000, */ 0x0000, /* 0000000000000000, */ 0x0000, /* 0000000000000000, */ 0x0000, /* 0000000000000000, */ 0x0000 } /* 0000000000000000 } */ I have a little filter that generates the whole line from the text within the comments, but it would be nice if the compiler (or the pre-processor) could do this. What I would like to be able to do is to declare binary constants in some form like (just a suggestion): 0b#01000100 If anyone reading this has the ear of ANSII, could they pass this suggestion on? If it's too late for C, how about in C++ ? Notes from some competing (-:) languages FORTRAN 77 (UTX/32 from Gould) B'00100101' c I've seen it in other dialects DOMAIN Pascal (from Apollo) 2#10010 { I've seen it in other dialects } Smalltalk-80 2r1111110 Icon 2R11011 OK, the first 2 are extensions to awkward languages, and the last 2 aren't system implementation languages (:-) -------------------------------------------------------------------------------- George Zipperlen george@apollo.lap.upenn.edu Language Analysis Project george@hyper.lap.upenn.edu University of Pennsylvania Generic Disclaimer Philadelphia, Pa. Cute saying --------------------------------------------------------------------------------