Hexadecimal Float64 creation

x = 0x.4p-1
0.125

What is the maths behind it, because I know 0.4 * 2^-1 = 0.2
I’m confused as to why that returns 0.125 in Julia, please enlighten me if I’m missing something

Because it is hexadecimal, the part behind the dot is also hexadecimal. So 0.4 is not \frac{4}{10}, it is \frac{4}{16} = 0.25. So giving it an exponent of p-1 (in this case p is base 2) is dividing by 2, yielding 0.125.

1 Like

Oh I see. Thank you so much

just a readability hint: use a leading 0 before the decimal point 0x0.4p-1

1 Like

Oh thank you