# Unable to read back floating-point values when using MMIO read

**URL:** <https://discuss.pynq.io/t/unable-to-read-back-floating-point-values-when-using-mmio-read/2519>\
**Category:** Support\
**Created:** [April 8, 2021, 10:45am UTC](https://discuss.pynq.io/t/unable-to-read-back-floating-point-values-when-using-mmio-read/2519 "2021-04-08T10:45:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![PeterOgden](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/peterogden/32/55_2.png) [@PeterOgden](https://discuss.pynq.io/u/PeterOgden)\
**Post date:** [April 8, 2021, 12:32pm UTC](https://discuss.pynq.io/t/unable-to-read-back-floating-point-values-when-using-mmio-read/2519/2 "2021-04-08T12:32:12Z")

</div>

There are a couple of ways of reading/writing floats. One is convert to/from an integer in your code:

```
f = struct.unpack('f', struct.pack('I', device.read(0x20)))[0]

```

Alternatively you can cast the entire address space to an array of float and access the registers through that: equivalently

```
ar = device.mmio.array.view('f')
f = ar[0x8]

```

Note that in this second way you need use indexes in the array rather than addresses.

You should also do something similar for writing floating point values - `.write` will also expect an int so floating point values may be converted to integers rather than written out bit-correctly.

Peter

---

_[View the full topic](https://discuss.pynq.io/t/unable-to-read-back-floating-point-values-when-using-mmio-read/2519)._
