# \[Solved\] Hex to 32-bit float

**URL:** <https://forums.losant.com/t/solved-hex-to-32-bit-float/1339>\
**Category:** Help\
**Tags:** hex, function\
**Created:** [December 18, 2018, 9:48pm UTC](https://forums.losant.com/t/solved-hex-to-32-bit-float/1339 "2018-12-18T21:48:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Calvin\_Foo](https://avatars.discourse-cdn.com/v4/letter/c/71e660/32.png) [@Calvin\_Foo](https://forums.losant.com/u/Calvin_Foo)\
**Post date:** [December 18, 2018, 9:48pm UTC](https://forums.losant.com/t/solved-hex-to-32-bit-float/1339/1 "2018-12-18T21:48:44Z")

</div>

how to convert hex (in string) to 32-bit float (IEEE 754)?

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [December 19, 2018, 12:02am UTC](https://forums.losant.com/t/solved-hex-to-32-bit-float/1339/2 "2018-12-19T00:02:39Z")

</div>

You’ll have to use a [Function Node](https://docs.losant.com/workflows/logic/function/) to achieve this. The Function Node exposes the [Buffer Object](https://nodejs.org/api/buffer.html), which is very good an doing conversions like this.

So for example, if I have a hex string on the payload that represents the float 3.14159 at `data.hex`, I can convert it back to the float using the following function:

```javascript
var hex = payload.data.hex;
var b = Buffer.from(hex, 'hex');
var value = b.readFloatLE(0);
payload.data.value = value; // 3.14159

```

You can now access the float value in the following nodes on the `data.value` payload path.

---

<div class="post-metadata">

**Author:** ![Tim\_Hoffman](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@Tim\_Hoffman](https://forums.losant.com/u/Tim_Hoffman)\
**Post date:** [January 22, 2019, 1:50am UTC](https://forums.losant.com/t/solved-hex-to-32-bit-float/1339/5 "2019-01-22T01:50:02Z")

</div>

Hi Brandon.

Had no idea the Buffer object was exposed. I can’t find any documentation in Losant relating to this.

Can you outline what other node api/object/entities are also exposed in the function node or point to documentation ?

Also is the Buffer object exposed on the Edge as well as Application workflows ?

Thanks

Tim

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [January 22, 2019, 3:38am UTC](https://forums.losant.com/t/solved-hex-to-32-bit-float/1339/6 "2019-01-22T03:38:37Z")

</div>

For cloud workflows, Buffer is the only additional object available. For edge workflows, since they run on your own hardware, you can use `require` and import any core NodeJS module you’d like.

If you want to get fancy, you can even extend the base agent Docker container and globally install any npm module. If it’s installed globally, you can then use `require` in the Function Node to use it.

The Function Node doesn’t support async execution, so that does limit available modules to things that run synchronously, but still opens a lot of options on the edge.

The documentation could use more details. Thanks for pointing that out!
