Go Down

Topic: Binary Formatter "B" works only on bytes (Read 3180 times) previous topic - next topic


I was trying to format some 16 bit constants in binary format and noticed that the handy binary formatter "B" seems to work only on bytes and not ints (16 bits).

Paul Badger


As a workaround you can do this:

int x = (B11111111 << 8) | B00000000;

This will get you the same thing as if "B1111111100000000" existed.


May 13, 2007, 06:08 pm Last Edit: May 13, 2007, 08:08 pm by jlndrr Reason: 1
it seems that these formaters are just defined constant :

#define B11111110 254
#define B11111111 255

in binary.h

so you could also define your own set, I suppose, for a whole 16bit integer. Don't forget to add some zeros, like here :

#define B1000 8
#define B01000 8
#define B001000 8
#define B0001000 8
#define B00001000 8

That would be a lot of constants !!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131