• Welcome to Dark Bit Factory & Gravity.
 

[C++] Hex And Binary

Started by Clyde, March 10, 2009

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Clyde

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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

benny!

@Clyde:

For Hex use 0x as prefix.
For bin I do not know. AFAIK there is no
explicit syntax - but maybe I am wrong  ::)
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Shockwave

Benny is right, there is no explicit syntax for binary numbers, but clyde, you should be using hex anyway :)
Shockwave ^ Codigos
Challenge Trophies Won:

Clyde

thanks for the info :)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Jim

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
Challenge Trophies Won: