Skip to content

Commit a3ac1d6

Browse files
committed
Fix number formatting, 0.2.3
1 parent 6e5c8cf commit a3ac1d6

File tree

5 files changed

+165
-187
lines changed

5 files changed

+165
-187
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.2.3
2+
3+
- Remove experimental number formatter
4+
15
# 0.2.2
26

37
- Fix theme switcher on Webkit (Tauri)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "kalkki",
33
"private": true,
4-
"version": "0.2.2",
4+
"version": "0.2.3",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src/math/internal/large-number.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatNumber } from "@/util/number-formatting";
1+
import { toSignificantDigits } from "@/util/number-formatting";
22
import { type GMPLib, init } from "gmp-wasm";
33

44
// Allows us to chain operations and run them in one go
@@ -436,7 +436,7 @@ export class LargeNumber {
436436
}
437437

438438
toSignificantDigits(digits: number) {
439-
const significant = formatNumber(this.value, digits, false, "normal");
439+
const significant = toSignificantDigits(this.value, digits);
440440

441441
// If the number has a scientific notation of exactly the bit precision (256 = 77), we should count it as zero (for example sin(pi) != 0)
442442
if (significant.toString().endsWith("-77")) {

src/math/worker.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { calculate } from "@/math/index";
22
import { LargeNumber } from "@/math/internal/large-number";
33
import { deserializeUserspace, serializeUserspace } from "@/util";
4-
import { formatNumber } from "@/util/number-formatting";
4+
import { toSignificantDigits } from "@/util/number-formatting";
55
import { ok } from "neverthrow";
66

77
type Request = {
@@ -37,12 +37,7 @@ self.onmessage = async (e) => {
3737
// Round the number to 100 digits for transport and storage to save memory
3838
const val: Record<string, unknown> = {};
3939
if (res.value.value) {
40-
val.value = formatNumber(
41-
res.value.value?.toString() ?? "",
42-
100,
43-
false,
44-
"normal",
45-
);
40+
val.value = toSignificantDigits(res.value.value?.toString() ?? "", 100);
4641
}
4742
if (res.value.userSpace) {
4843
val.userSpace = JSON.stringify(serializeUserspace(res.value.userSpace));

0 commit comments

Comments
 (0)