# How do I parse a binary into a 32 bit float?

**URL:** <https://erlangforums.com/t/how-do-i-parse-a-binary-into-a-32-bit-float/2216>\
**Category:** Questions / Help\
**Tags:** binaries, float\
**Created:** [December 30, 2022, 1:40pm UTC](https://erlangforums.com/t/how-do-i-parse-a-binary-into-a-32-bit-float/2216 "2022-12-30T13:40:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fylke](https://erlangforums.com/user_avatar/erlangforums.com/fylke/32/1729_2.png) [@Fylke](https://erlangforums.com/u/Fylke)\
**Post date:** [December 30, 2022, 1:40pm UTC](https://erlangforums.com/t/how-do-i-parse-a-binary-into-a-32-bit-float/2216/1 "2022-12-30T13:40:07Z")

</div>

I’m playing around with binaries, and in the docs it says that floats can be either 64, 32, or 16 bits. I can parse 64 bits just fine, but I can’t figure out how to parse 32:

```erlang
55> <<A/float>> = <<1,17,0,42,43,11,24,11>>.
<<1,17,0,42,43,11,24,11>>
56> A.
1.5494220711692294e-303
57> <<B/float>> = <<1,17,0,42>>.            
** exception error: no match of right hand side value <<1,17,0,42>>

```

How am I supposed to write it?

---

<div class="post-metadata">

**Author:** ![dischoen](https://erlangforums.com/user_avatar/erlangforums.com/dischoen/32/695_2.png) [@dischoen](https://erlangforums.com/u/dischoen)\
**Post date:** [December 30, 2022, 2:12pm UTC](https://erlangforums.com/t/how-do-i-parse-a-binary-into-a-32-bit-float/2216/2 "2022-12-30T14:12:20Z")

</div>

Add the size in bits:  
\<\<B:32/float\>\> = \<\<1,17,0,42\>\>.

The complete bit syntax is here:  
[https://www.erlang.org/doc/programming\_examples/bit\_syntax.html#](https://www.erlang.org/doc/programming_examples/bit_syntax.html#)

---

<div class="post-metadata">

**Author:** ![Fylke](https://erlangforums.com/user_avatar/erlangforums.com/fylke/32/1729_2.png) [@Fylke](https://erlangforums.com/u/Fylke)\
**Post date:** [December 30, 2022, 2:14pm UTC](https://erlangforums.com/t/how-do-i-parse-a-binary-into-a-32-bit-float/2216/3 "2022-12-30T14:14:57Z")

</div>

Ah, so 64 bits is the default, gotcha. Thanks!
