Skip to content

Commit f36570f

Browse files
ids1024mmstick
authored andcommitted
improv(calc): Use BigNumber representation
Resolves #1120. This should better match the behavior of calculators like gnome-calculator. As far as I'm aware, the only downside of this is performance. Which probably isn't an issue when just using math.js as a calculator (vs trying to script loops of calculations).
1 parent 6c9c847 commit f36570f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/plugins/calc/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const SCRIPT_DIR = GLib.path_get_dirname(new Error().stack.split(':')[0].slice(1
88
/** Add our directory so we can import modules from it. */
99
imports.searchPath.push(SCRIPT_DIR)
1010

11-
const { evaluate } = imports.math.math;
11+
const math = imports.math.math;
12+
math.config({number: 'BigNumber'});
1213

1314
/**
1415
* Request received by the Pop Shell launcher
@@ -44,7 +45,7 @@ class App {
4445
this.last_query = input.substr(1)
4546

4647
try {
47-
this.last_value = evaluate(this.last_query).toString()
48+
this.last_value = math.evaluate(this.last_query).toString()
4849
} catch (e) {
4950
this.last_value = this.last_query + ` x = ?`
5051
}

0 commit comments

Comments
 (0)