i want a constant constint hex_numb; and how do you define a hexidecimal number in int format? Then i want this const to be prefixed or suffixed on a larger or smaller hexidecimal number. How do I do this?
1 2 3 4 5 6
constint hex_numb_1 ;
constint hex_numb_2 ;
constint hex_numb_3;
constint hex_numb_main = appendToHexInOrder( hex_numb_3 , hex_numb_1 , hex_numb_2 );
//appendToHexInOrder takes the order of the arguments and appends them in front or in back.
To specify a hex number as a constant, just prefix the number by 0x
0x10 is 16 decimal etc
Usually when dealing with hex numbers, you use unsigned base type.
constunsignedint hex_numb_1 = 0x10;
What is function appendToHexInOrder() supposed to do? You are passing 3 int numbers (lets say 32 bits) and want to append them. So you end up with a 96 bit number???
this comes back to what I said before, a number IS a number.
there is no 'hex' in terms of int. the only 'hex' is how you PRINT it onscreen.
that said, the above math works when you print it out, and you can also bit-twiddle it.
lets look at bit-twiddle because it may help clear some things up.
a byte is 2 hex digits. It can be 0-256, or 00 to FF. Note that 16*16 is 256. Note that a byte is also 8 bits. Base 2 and base 16 are related because exponents. As 16 is a power of 2, then, groups of base 2 represent groups of base 16: it turns out that 4 bits represent 1 hex digit.
so for each hex digit, you can num << 4; which is exactly the same as multiply by 16 above. You can then use | num2, which is the same as adding it, to set the back half of the bits.
all this is heavily tied to exponents, which means they are tied to logs. you can use a log to find out how many hex digits a number has ignoring leading zeros.