# Square root issue

**URL:** https://forum.repebble.com/t/square-root-issue/1001
**Category:** Firmware Developer Corner
**Created:** [June 19, 2026, 1:48am UTC](https://forum.repebble.com/t/square-root-issue/1001 "2026-06-19T01:48:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sumbloke](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@sumbloke](https://forum.repebble.com/u/sumbloke)
#### Post date: [June 19, 2026, 1:48am UTC](https://forum.repebble.com/t/square-root-issue/1001/1 "2026-06-19T01:48:37Z")

</div>

I was developing my first app and kept having the app crash when running on my watch (Pebble Time 2) in certain situations, while it worked fine in the emulator. I eventually tracked down the issue to the sqrt() function being pulled in from the standard \<math.h\> library.

It seems that on the watch, the sqrt function works fine when the number passed in is a perfect square, but doesn’t calculate it properly otherwise. I haven’t figured out exactly what it does in those scenarios, but I would suspect it’s returning NaN or similar.

Not an urgent issue for me, because I don’t need an exact value and was able to put in a “good enough” algorithm for my purpose. But it might trip up some others, especially since the emulator seems to calculate the square roots correctly regardless of input.
