@abaplint/runtime 2.3.1 → 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.
@@ -117,6 +117,9 @@ function eq(left, right) {
117
117
  if (r === "") {
118
118
  r = 0;
119
119
  }
120
+ else if (r.includes(".")) {
121
+ r = parseFloat(r);
122
+ }
120
123
  else {
121
124
  r = parseInt(r, 10);
122
125
  }
@@ -8,7 +8,12 @@ function parse(val) {
8
8
  return val;
9
9
  }
10
10
  else if (typeof val === "string") {
11
- return parseInt(val, 10);
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
- return new types_1.Float().set((0, _parse_1.parse)(left) + (0, _parse_1.parse)(right));
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
@@ -10,6 +10,7 @@ export declare class Packed implements INumeric {
10
10
  qualifiedName?: string;
11
11
  });
12
12
  getQualifiedName(): string | undefined;
13
+ private round;
13
14
  set(value: INumeric | number | string): void;
14
15
  getLength(): number;
15
16
  getDecimals(): number;
@@ -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());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",