www.digitalmars.com         C & C++   DMDScript  

D - integer literals - in binary

reply imr1984 <imr1984_member pathlink.com> writes:
ok so all C based languages can do this:

int x = 0xFF; //255

what about this:

int x = 0b11111111; //255

this would be very useful especially for defining flags
Feb 03 2004
next sibling parent Vathix <vathix dprogramming.com> writes:
 int x = 0b11111111; //255
 
 this would be very useful especially for defining flags
It's supported. Give it a try. -- Christopher E. Miller www.dprogramming.com
Feb 03 2004
prev sibling next sibling parent Stephan Wienczny <wienczny web.de> writes:
imr1984 wrote:
 ok so all C based languages can do this:
 
 int x = 0xFF; //255
 
 what about this:
 
 int x = 0b11111111; //255
 
 this would be very useful especially for defining flags
 
 
Have a look at http://digitalmars.com/d/lex.html There look at Integer Literals -> binary D supports exactly the notation you suggest... Stephan
Feb 03 2004
prev sibling parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
AFAIUI, D already supports this, although I do not know the precise syntax

"imr1984" <imr1984_member pathlink.com> wrote in message
news:bvo5a9$2mqs$1 digitaldaemon.com...
 ok so all C based languages can do this:

 int x = 0xFF; //255

 what about this:

 int x = 0b11111111; //255

 this would be very useful especially for defining flags
Feb 03 2004