• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++ help: quick question... how do I specify which base a number is?

You mean prepend a number so when you read it, you know what base it's in?

If I see 0x123 - its hex
If I see 01010 - I'm *assuming* its binary
If I see 12351 - I"m *assuming* its base10

I don't think other than the 0x nomenclature for Hex, that there are standardized ways to represent the other Bases, other than using the base as a subscript after the actual number like textbooks do.
 
Originally posted by: her209
Why do you have to store it in a base? Why not just convert it when you're going to display it?


I have to do a bunch of masking of addresses and opcodes. I'm converting everything to decimal for input now, but it'd be clearer in some cases if I could use binary. But if I use "1010111" the compiler will think it's decimal.
 
Originally posted by: Jumpem
Originally posted by: EmperorIQ
do you mean specify the base for a reader to read? or for the compiler?


compiler

you would have to represent it as a hex and mask it from there, for example, if you want to represent binary 1111 you'd do

0x0000F
 
Back
Top