-
Notifications
You must be signed in to change notification settings - Fork 1
signExtend
Subhajit Sahu edited this page Jul 25, 2022
·
11 revisions
[Sign extend] variable bit-width integer.
signExtend(x, [w])
// x: variable bit-width integer
// w: bit width (32)
const xbit = require('extra-bit');
xbit.signExtend(15, 4);
// → -1 (1111 ⇒ -1)
xbit.signExtend(3, 3);
// → 3 (011 ⇒ 3)
xbit.signExtend(4, 3);
// → -4 (100 ⇒ -4)