# Hexadecimal Float64 creation

**URL:** <https://discourse.julialang.org/t/hexadecimal-float64-creation/83936>\
**Category:** General Usage\
**Created:** [July 8, 2022, 9:31am UTC](https://discourse.julialang.org/t/hexadecimal-float64-creation/83936 "2022-07-08T09:31:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![uje](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uje](https://discourse.julialang.org/u/uje)\
**Post date:** [July 8, 2022, 9:31am UTC](https://discourse.julialang.org/t/hexadecimal-float64-creation/83936/1 "2022-07-08T09:31:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![suavesito](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/suavesito/32/34386_2.png) [@suavesito](https://discourse.julialang.org/u/suavesito)\
**Post date:** [July 8, 2022, 9:38am UTC](https://discourse.julialang.org/t/hexadecimal-float64-creation/83936/2 "2022-07-08T09:38:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![uje](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uje](https://discourse.julialang.org/u/uje)\
**Post date:** [July 8, 2022, 1:08pm UTC](https://discourse.julialang.org/t/hexadecimal-float64-creation/83936/3 "2022-07-08T13:08:13Z")

</div>

Oh I see. Thank you so much

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 8, 2022, 3:13pm UTC](https://discourse.julialang.org/t/hexadecimal-float64-creation/83936/4 "2022-07-08T15:13:37Z")

</div>

> [@uje](#):
>
> x = 0x.4p-1

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

---

<div class="post-metadata">

**Author:** ![uje](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uje](https://discourse.julialang.org/u/uje)\
**Post date:** [July 8, 2022, 7:00pm UTC](https://discourse.julialang.org/t/hexadecimal-float64-creation/83936/5 "2022-07-08T19:00:08Z")

</div>

Oh thank you
