From 822e21cfd362a28a0fdc40c906d22c734fae8328 Mon Sep 17 00:00:00 2001 From: Michael Ennen Date: Wed, 25 Dec 2024 19:12:22 -0700 Subject: [PATCH] Use a much faster roundTo implementation (no conversion back/forth to string). --- moody.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/moody.js b/moody.js index 5c98089..327592f 100644 --- a/moody.js +++ b/moody.js @@ -3,9 +3,8 @@ import { Vector3 } from "./math.js" const sineOfOneArcsecond = 0.00000484813 function roundTo(n, numDecimalPlaces) { - const multiplicator = Math.pow(10, numDecimalPlaces) - n = parseFloat((n * multiplicator).toFixed(11)) - return Math.round(n) / multiplicator + const factor = Math.pow(10, numDecimalPlaces) + return Math.round(n * factor) / factor } class Unit {