「Mery 電卓 (bc コマンド使用版)」の版間の差分
| 114行目: | 114行目: | ||
try { | try { | ||
var exp_replaced = replaceExpression(exp) | var exp_replaced = replaceExpression(exp) | ||
.replace(/([^;]*%[^;]*)/g, "scale=0; $1; scale= | .replace(/([^;]*%[^;]*)/g, "scale=0; $1; scale=15; "); // 剰余計算を整数にする | ||
const exec = shell.Exec(busyboxPath + " bc -l", "scale= | const exec = shell.Exec(busyboxPath + " bc -l", "scale=15; " + exp_replaced); | ||
if (exec.ExitCode !== 0) { | if (exec.ExitCode !== 0) { | ||
throw new Error("計算エラー: " + exec.StdErr); | throw new Error("計算エラー: " + exec.StdErr); | ||
| 122行目: | 122行目: | ||
var result_str = exec.StdOut | var result_str = exec.StdOut | ||
.trim() | .trim() | ||
.replace(/^\./gm, " | .replace(/^(-)?\./gm, "$10.") | ||
.replace(/(\.[0-9]*?)0+$/gm, "$1") | .replace(/(\.[0-9]*?)0+$/gm, "$1") | ||
.replace(/\.$/gm, ""); | .replace(/\.$/gm, ""); | ||
スポンサーリンク