「Mery 電卓 (bc コマンド使用版)」の版間の差分
| (同じ利用者による、間の1版が非表示) | |||
| 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, ""); | ||
| 274行目: | 274行目: | ||
== 更新履歴 == | == 更新履歴 == | ||
* 2025-11-29 計算結果が「-0.1」のような1未満の負の小数になる場合に「-.1」のような表示になってしまう不具合を修正。小数計算精度を scale=10 から scale=15 へ調整 | |||
* 2025-10-26 「5 - 3.0」のような「小数以下が『.0』になる計算」で「.」だけが出力に残ってしまう不具合を修正 | |||
* 2025-10-25 公開 | * 2025-10-25 公開 | ||
スポンサーリンク