| 32 | return this.qualifiedName; |
| 33 | } |
| 34 | |
| 35 | public set(value: INumeric | ICharacter | Hex | string | number | bigint | Integer8 | Integer | Float | DecFloat34) { |
| 36 | if (typeof value === "number") { |
| 37 | this.value = BigInt(value); |
| 38 | } else if (typeof value === "bigint") { |
| 39 | this.value = value; |
| 40 | } else if (typeof value === "string") { |
| 41 | if (value.endsWith("-")) { |
| 42 | value = "-" + value.substring(0, value.length - 1); |
| 43 | } |
| 44 | if (value.trim().length === 0) { |
| 45 | value = "0"; |
| 46 | } else if (digits.test(value) === false) { |
| 47 | throwError("CX_SY_CONVERSION_NO_NUMBER"); |
| 48 | } |
| 49 | this.value = BigInt(value); |
| 50 | } else if (value instanceof Float || value instanceof DecFloat34) { |
| 51 | this.set(roundHalfAwayFromZero(value.getRaw())); |
| 52 | } else if (value instanceof Hex || value instanceof XString || value instanceof HexUInt8) { |
| 53 | if (value.get().length === 16) { |
| 54 | const lv_bit = new Character(); |
| 55 | getBit(new Integer().set(1), value, lv_bit); |
| 56 | if (lv_bit.get() === "1") { |
| 57 | const val = BigInt("0x" + value.get()); |
| 58 | this.value = val - BigInt("0x10000000000000000"); |
| 59 | } else { |
| 60 | this.value = BigInt("0x" + value.get()); |
| 61 | } |
| 62 | } else { |
| 63 | // todo, what if the input is longer than 16 bytes? |
| 64 | this.value = BigInt("0x" + value.get()); |
| 65 | } |
| 66 | } else { |
| 67 | this.set(value.get()); |
| 68 | } |
| 69 | return this; |
| 70 | } |
| 71 | |
| 72 | public clear(): void { |