From 95d8bca619564804d6c858b38498696a7747aa78 Mon Sep 17 00:00:00 2001 From: NriotHrreion Date: Thu, 6 Jun 2024 13:17:30 +0800 Subject: [PATCH] fix(graphics): 0 being transformed into infinity through `numberToString()` --- src/renderer/Graphics.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderer/Graphics.ts b/src/renderer/Graphics.ts index e2858d7..4c57f05 100644 --- a/src/renderer/Graphics.ts +++ b/src/renderer/Graphics.ts @@ -381,6 +381,8 @@ export default class Graphics { public static numberToString(n: number, fractionDigits?: number): string { const abs = Math.abs(n); + if(abs === 0) return fractionDigits !== undefined ? (0).toFixed(fractionDigits) : "0"; + if(abs < minSn && abs > maxSn) { return fractionDigits !== undefined ? n.toFixed(fractionDigits) : n.toString(); }