Compare commits

..

2 Commits
0.3.5 ... 0.3.6

Author SHA1 Message Date
Herculino Trotta
4005a83a0d Merge pull request #32
fix(calculator): rounding errors
2025-01-07 16:17:00 -03:00
Herculino Trotta
f81f1d83fd fix(calculator): rounding errors 2025-01-07 16:16:26 -03:00
2 changed files with 9 additions and 4 deletions

View File

@@ -66,7 +66,7 @@
})
end
then set expr to it
then call math.evaluate(expr)
then call math.evaluate(expr).toNumber()
if result exists and result is a Number
js(result)
return result.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40})

View File

@@ -2,18 +2,23 @@ import _hyperscript from 'hyperscript.org/dist/_hyperscript.min';
import './_htmx.js';
import Alpine from "alpinejs";
import mask from '@alpinejs/mask';
import { create, all } from 'mathjs';
import {create, all} from 'mathjs';
window.Alpine = Alpine;
window._hyperscript = _hyperscript;
window.math = create(all, { });
window.math = create(all, {
number: 'BigNumber', // Default type of number:
// 'number' (default), 'BigNumber', or 'Fraction'
precision: 64, // Number of significant digits for BigNumbers
relTol: 1e-60,
absTol: 1e-63
});
Alpine.plugin(mask);
Alpine.start();
_hyperscript.browserInit();
const successAudio = new Audio("/static/sounds/success.mp3");
const popAudio = new Audio("/static/sounds/pop.mp3");
window.paidSound = successAudio;