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

Commit

Permalink
Fixes #228 - Floating Point Math Issues. Numbers are fixed to maximum…
Browse files Browse the repository at this point in the history
… precision of 10 decimals and converted to a string.
  • Loading branch information
cpriest committed Apr 20, 2017
1 parent 16e6619 commit 94a0cc3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/main/plugins/hain-plugin-math/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = (context) => {
try {
const ans = math.eval(query);
if (lo_isNumber(ans) || lo_isString(ans) || (lo_isObject(ans) && lo_has(ans, 'value'))) {
const ansString = ans.toString();
const ansString = Number.parseFloat(ans.toPrecision(10)).toString();
const isResultMeaningful = (ansString.trim() !== query.trim());
if (isResultMeaningful || showRedundantResult)
return ansString;
Expand Down

0 comments on commit 94a0cc3

Please sign in to comment.