3 ms·
Aren't floating point comparisons frowned upon? https://github.com/google/pebble/blob/main/src/libc/math/floor.c#L55 https://github.com/google/pebble/blob/main
by abhishekjha 2y ago
Aren't floating point comparisons frowned upon?
https://github.com/google/pebble/blob/main/src/libc/math/floor.c#L55 https://github.com/google/pebble/blob/main/src/libc/math/flo...
I guess you can freeze some compiler options to give you consistent results.
- Gigachad 2y agoI've only done a little bit of arduino programming, but for that you had to import a whole library for floating point math which took a huge amount of space, and many chips didn't even have hardware support for it.
- deleted 2y ago[deleted]
- kccqzy 2y agoThis case looks okay. It's converting a double to an int64_t and then back to double for comparison. It doesn't really suffer from the typical reason why floating point comparison is frowned upon, such as catastrophic cancellation. I've once optimized a function to be faster, and in a unit test asserted that the old slower version gives exactly the same floating point answer as the new optimized version. It's doable in some cases.