(val, format, safeOp)
| 34 | return BigInt("1" + result.substring(0, decimals)); |
| 35 | } |
| 36 | function checkValue(val, format, safeOp) { |
| 37 | const width = BigInt(format.width); |
| 38 | if (format.signed) { |
| 39 | const limit = (BN_1 << (width - BN_1)); |
| 40 | (0, errors_js_1.assert)(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", { |
| 41 | operation: safeOp, fault: "overflow", value: val |
| 42 | }); |
| 43 | if (val > BN_0) { |
| 44 | val = (0, maths_js_1.fromTwos)((0, maths_js_1.mask)(val, width), width); |
| 45 | } |
| 46 | else { |
| 47 | val = -(0, maths_js_1.fromTwos)((0, maths_js_1.mask)(-val, width), width); |
| 48 | } |
| 49 | } |
| 50 | else { |
| 51 | const limit = (BN_1 << width); |
| 52 | (0, errors_js_1.assert)(safeOp == null || (val >= 0 && val < limit), "overflow", "NUMERIC_FAULT", { |
| 53 | operation: safeOp, fault: "overflow", value: val |
| 54 | }); |
| 55 | val = (((val % limit) + limit) % limit) & (limit - BN_1); |
| 56 | } |
| 57 | return val; |
| 58 | } |
| 59 | function getFormat(value) { |
| 60 | if (typeof (value) === "number") { |
| 61 | value = `fixed128x${value}`; |
no outgoing calls
no test coverage detected