UNPKG

@abaplint/runtime

Version:
23 lines 916 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.bitnot = bitnot; const builtin_1 = require("../builtin"); const types_1 = require("../types"); // note: javascript bitwise negate doesnt work well for long hex values function bitnot(right) { const len = (0, builtin_1.xstrlen)({ val: right }).get(); let not = ""; for (let i = 0; i < len; i++) { const byte = right.getOffset({ offset: i, length: 1 }); let binary = parseInt(byte.get(), 16).toString(2).padStart(8, "0"); binary = binary.replace(/0/g, "2"); binary = binary.replace(/1/g, "0"); binary = binary.replace(/2/g, "1"); const hex = parseInt(binary, 2).toString(16).padStart(2, "0"); not += hex; } const ret = new types_1.Hex({ length: right.get().length / 2 }); ret.set(not.toUpperCase()); return ret; } //# sourceMappingURL=bit-not.js.map