Dark Bit Factory & Gravity
PROGRAMMING => C / C++ /C# => Topic started by: Clyde on March 10, 2009
-
Anybody know what the Hex and Binary symbols are please?
In FreeBASIC they are &H for Hex, and &B for Binary.
In Blitz they are the same symbol of $.
Thanks again,
The Little Fuzzy Wuzzy.
-
@Clyde:
For Hex use 0x as prefix.
For bin I do not know. AFAIK there is no
explicit syntax - but maybe I am wrong ::)
-
Benny is right, there is no explicit syntax for binary numbers, but clyde, you should be using hex anyway :)
-
thanks for the info :)
-
Yep, 0x prefix for hex, but no binary, you can do macros like:
#define BIN(a,b,c,d,e,f,g,h) (((a)<<7)|((b)<<6)|((c)<<5)|((d)<<4)|((e)<<3)|((f)<<2)|((g)<<1)|(h))
BIN(1,0,1,0,1,1,1,1)
will then work.
Interestingly C and C++ support octal as well using 0 prefix. So 010 is actually 8 in decimal.
Jim