hexadecimals

 

Hello MQL4 community,

To my knowledge, hex decimal base value representation is 0-15 (16 values) and its hex value representation is 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F (totaling 16 values). If my previous statement is valid, would hex decimal representation of seventeen be eleven in hex (I'm preppin' for binary conversion from hex values).

Maybe William Roeder can be of assistance?


Thank you

 
WhooDoo22:

Hello MQL4 community,

To my knowledge, hex decimal base value representation is 0-15 (16 values) and its hex value representation is 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F (totaling 16 values). If my previous statement is valid, would hex decimal representation of seventeen be eleven in hex (I'm preppin' for binary conversion from hex values).

eleven is a number in base 10 and not a hex number,  what you are looking for is 0x11  or hex one one


It's good to see you working on the fundamentals  

 

Conversion from decimal seventeen to a hexadecimal value. I calculated eleven as decimal seventeen's hex value.

What say you to this Simon?

Thank you

 

WhooDoo22:

Conversion from decimal seventeen to a hexadecimal value. I calculated eleven as decimal seventeen's hex value.

(I'm preppin' for binary conversion from hex values).

Maybe William Roeder can be of assistance?

  1. seventeen to hex is one one hex, NOT eleven. Do not use normal words - they imply decimal.
  2. No need, just write HexToInt and IntToBinary (or IntToBase)
  3. In what way?
 
WhooDoo22:

Conversion from decimal seventeen to a hexadecimal value. I calculated eleven as decimal seventeen's hex value.

eleven is the number following on from ten and is a base ten number . . .  eleven is not the same as 11 unless you specify the base as being base ten,  11 in binary == three in base ten,   11 in octal == nine in base ten,   11 in hex = seventeen in base ten,  11 in base ten == eleven,  there is no eleven in hex,  it doesn't exist.
 

William,

"seventeen to hex is one one hex, NOT eleven. Do not use normal words - they imply decimal."

Alright.

"No need, just write HexToInt and IntToBinary (or IntToBase)"

Yeah.

"In what way?"

Your confirmation to my calculation of 11 (one, one). I calculated 11 because 16*0=0, 0+1=1. OK so I got 1, next I still need 16 so I'll move left a decimal place to 16*1=16. 16+1=17. The way I wrote it out is "scribble-scrabble" but I think you get what it is I'm doing.


Simon,

"eleven is the number following on from ten and is a base ten number . . .  eleven is not the same as 11 unless you specify the base as being base ten,  11 in binary == three in base ten,   11 in octal == nine in base ten,   11 in hex = seventeen in base ten,  11 in base ten == eleven,  there is no eleven in hex,  it doesn't exist."

Yeah, the result is 11 so I called it eleven but its one, one.

Thank you

 
WhooDoo22:


"In what way?"

Your confirmation to my calculation of 11 (one, one). I calculated 11 because 16*0=0, 0+1=1. OK so I got 1, next I still need 16 so I'll move left a decimal place to 16*1=16. 16+1=17. The way I wrote it out is "scribble-scrabble" but I think you get what it is I'm doing.

This is how all numbers regardless of base are written,  to the left of the decimal we have . . .

base^n. . . base^2base^1base^0

 

so for base 10 we have

base^n . . . base^4 = 10000base^3 = 1000base^2 = 100base^1 = 10base^0 = 1

 

 the base 10 number   308 = 3 * 100 + 0 * 10 + 8 * 1

 

for base 16 (Hex) we have

base^n. . . .base^2 = 256base^1 = 16base^0 = 1

 

 the base 16 number  11 = 1 * 16 + 1 * 1

Reason: