# Need help with micro:bit math

**URL:** https://forum.makecode.com/t/need-help-with-micro-bit-math/11831
**Category:** Help
**Tags:** graphics-and-math
**Created:** [January 22, 2022, 12:31am UTC](https://forum.makecode.com/t/need-help-with-micro-bit-math/11831 "2022-01-22T00:31:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tcozz](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@tcozz](https://forum.makecode.com/u/tcozz)
#### Post date: [January 22, 2022, 12:31am UTC](https://forum.makecode.com/t/need-help-with-micro-bit-math/11831/1 "2022-01-22T00:31:37Z")

</div>

Hello,

I have a student who encountered something odd in MakeCode. The student set a variable to 16.9 at program start. Then “On Shake” change the variable by -1.3. However then the variable is displaying as 15.599999999 instead of 15.6. Tried changing input to “On Tilt” or “On Button A Press” with same results. Tried setting variable to different numbers like 17.9 or 18.9 with similar results. However for some reason setting variable to 14.9 and subtracting 1.3 did indeed equal 13.6.

Any ideas what is happening?

Thanks

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [January 22, 2022, 12:41am UTC](https://forum.makecode.com/t/need-help-with-micro-bit-math/11831/2 "2022-01-22T00:41:19Z")

</div>

That’s because it’s a [floating point](https://en.wikipedia.org/wiki/Floating-point_arithmetic) number.

Computers only have so many bytes that they can use for each number they store. To make the numbers fit in that limited space, they store an approximation instead of the actual value. 99.9% of the time this isn’t a problem, because being .0000000001 off from the actual number is an acceptable amount of error. It does look confusing when you print it out, though!
