From 8d4704056498a74c77ece07c7a29a8eb6cc6ea67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Sat, 1 Feb 2020 17:32:06 +0100 Subject: [PATCH] Add optional printNaN to stringFloat --- static/js/floatUtils.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/static/js/floatUtils.js b/static/js/floatUtils.js index ae068a64..841e0623 100644 --- a/static/js/floatUtils.js +++ b/static/js/floatUtils.js @@ -1,6 +1,7 @@ class stringFloat{ - constructor(value) { + constructor(value,printNaN=true) { this.string=value + this.printNaN=printNaN } get Value(){ return parseFloat(this.string) @@ -9,10 +10,10 @@ class stringFloat{ return this.Value; } toString(){ - if (checkFloat(this.string)) { - return this.Value - } else { + if (checkFloat(this.string) && this.printNaN) { return this.string + } else { + return NaN.toString() } } }