Browse Source

Merge branch 'fixRealConvertion' of LInE/iVProg into master

GitAdmin 3 years ago
parent
commit
d90489b576
1 changed files with 9 additions and 1 deletions
  1. 9 1
      js/util/parseFromVisual.js

+ 9 - 1
js/util/parseFromVisual.js

@@ -1,5 +1,6 @@
 import { IVProgParser } from "../ast/ivprogParser";
 import * as Expressions from "../ast/expressions";
+import { Types } from "../typeSystem/types";
 
 const TYPES = {
   VARIABLE: "var",
@@ -102,7 +103,14 @@ function expressionWalker (expression) {
   } else {
     let value = expression.value;
     if (expression.value.toNumber) {
-      value = expression.value.toNumber();
+      if (
+        Types.REAL.isCompatible(expression.type) &&
+        expression.value.decimalPlaces() == 0
+      ) {
+        value = expression.value.toFixed(2);
+      } else {
+        value = expression.value.toNumber();
+      }
     }
     result = [
       {