@abaplint/runtime 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,7 +8,12 @@ function parse(val) {
|
|
|
8
8
|
return val;
|
|
9
9
|
}
|
|
10
10
|
else if (typeof val === "string") {
|
|
11
|
-
|
|
11
|
+
if (val.includes(".")) {
|
|
12
|
+
return parseFloat(val);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return parseInt(val, 10);
|
|
16
|
+
}
|
|
12
17
|
}
|
|
13
18
|
else if (val instanceof types_1.Float) {
|
|
14
19
|
return val.getRaw();
|
|
@@ -24,7 +24,8 @@ function add(left, right) {
|
|
|
24
24
|
else if ((right instanceof string_1.String || right instanceof types_1.Character) && Number.isInteger(Number(right)) && left instanceof types_1.Integer) {
|
|
25
25
|
return new types_1.Integer().set(left.get() + Number.parseInt(right.get(), 10));
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
const ret = new types_1.Float().set((0, _parse_1.parse)(left) + (0, _parse_1.parse)(right));
|
|
28
|
+
return ret;
|
|
28
29
|
}
|
|
29
30
|
exports.add = add;
|
|
30
31
|
//# sourceMappingURL=add.js.map
|
|
@@ -18,15 +18,19 @@ class Packed {
|
|
|
18
18
|
getQualifiedName() {
|
|
19
19
|
return this.qualifiedName;
|
|
20
20
|
}
|
|
21
|
+
round(value, places) {
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
return +(Math.round(value + "e+" + places) + "e-" + places);
|
|
24
|
+
}
|
|
21
25
|
set(value) {
|
|
22
26
|
if (typeof value === "number") {
|
|
23
27
|
this.value = value;
|
|
24
28
|
}
|
|
25
29
|
else if (typeof value === "string") {
|
|
26
|
-
this.value = parseFloat(value);
|
|
30
|
+
this.value = this.round(parseFloat(value), this.decimals);
|
|
27
31
|
}
|
|
28
32
|
else if (value instanceof float_1.Float) {
|
|
29
|
-
this.value = value.getRaw();
|
|
33
|
+
this.value = this.round(value.getRaw(), this.decimals);
|
|
30
34
|
}
|
|
31
35
|
else {
|
|
32
36
|
this.set(value.get());
|