Skip to content
This repository has been archived by the owner on Jun 29, 2019. It is now read-only.

hain-plugin-math: Rounding issue #228

Closed
ChristopherHaws opened this issue Mar 24, 2017 · 2 comments
Closed

hain-plugin-math: Rounding issue #228

ChristopherHaws opened this issue Mar 24, 2017 · 2 comments
Assignees

Comments

@ChristopherHaws
Copy link

Hello,

There seems to be a rounding issue with the built in calculator.

Steps to reproduce

  1. Open Hain
  2. Type =0.1+0.2 into the search bar

Expected behavior
I would expect for the result to be 0.3

Actual behavior
The result is showing up as 0.30000000000000004

image

Thanks!

@cpriest
Copy link
Member

cpriest commented Mar 24, 2017 via email

@ChristopherHaws
Copy link
Author

ChristopherHaws commented Mar 24, 2017

Looks like the "fix" is to use toFixed. I'm not sure the best way for you to determine how many decimal places to show however.

http://stackoverflow.com/questions/10473994/javascript-adding-decimal-numbers-issue

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed

http://floating-point-gui.de/basic/

@cpriest cpriest self-assigned this Apr 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants