# Expression rounding

**URL:** <https://forum.inductiveautomation.com/t/expression-rounding/27436>\
**Category:** Ignition\
**Created:** [August 14, 2019, 4:14pm UTC](https://forum.inductiveautomation.com/t/expression-rounding/27436 "2019-08-14T16:14:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigb](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@craigb](https://forum.inductiveautomation.com/u/craigb)\
**Post date:** [August 14, 2019, 4:14pm UTC](https://forum.inductiveautomation.com/t/expression-rounding/27436/1 "2019-08-14T16:14:27Z")

</div>

When I apply a round to one decimal it works, but not to 2 ? see image, why is that ?

 ![round2](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/6dbd5146ef852d6f27cf1d25ae75a8e2d8c85ad7.jpeg)

 ![round1](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/dea27c1905c7cad382f2f034363deba313c16ae3.jpeg)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 14, 2019, 5:17pm UTC](https://forum.inductiveautomation.com/t/expression-rounding/27436/2 "2019-08-14T17:17:01Z")

</div>

It’s expected behavior when you place the value back in a float or a double. It is an artifact of binary representation of fractions that repeat. Us humans use base 10, which has fractions that end if the least common denominator is a power of 2 and/or 5. Binary fractions repeat if the least common denominator isn’t a power of 2.  
round() gives you the _ **closest** _ binary representation of rounding to base 10.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 14, 2019, 5:22pm UTC](https://forum.inductiveautomation.com/t/expression-rounding/27436/3 "2019-08-14T17:22:51Z")

</div>

Wrapping the entire transform in `round` might work better. Doubles/floating points are weird.

---

<div class="post-metadata">

**Author:** ![craigb](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@craigb](https://forum.inductiveautomation.com/u/craigb)\
**Post date:** [August 14, 2019, 5:26pm UTC](https://forum.inductiveautomation.com/t/expression-rounding/27436/4 "2019-08-14T17:26:03Z")

</div>

![round2](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/1fd2275b2f2c04a92d0a40ccd6a766bbd5f2216a.jpeg)
