From 3147770dcec9f76d7137a5e05389ccdeed9a86df Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Mon, 29 Nov 2021 22:14:15 +0800 Subject: 2.6 --- 2/6.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to '2/6.c') diff --git a/2/6.c b/2/6.c index 67d7c09..a8f2120 100644 --- a/2/6.c +++ b/2/6.c @@ -19,16 +19,16 @@ int main(int argc, char *argv[]) { unsigned setbits(unsigned x, int p, int n, unsigned y) { unsigned yLO, yLOA, xUnset, xPrime; - // extract LO n bits from y + // extract n LO bits from y yLO = y & ~(~0 << n); - // align extracted LO bits of y to position p: + // align extracted bits to p: yLOA = yLO << (p + 1 - n); - // create mask with n bits from position p unset: + // mask with n bits from p unset: xUnset = (~0 << p) | ~(~0 << (p - n)); - // mask out n bits from x starting at position p: + // mask out n bits in x from p: xPrime = x & xUnset; return xPrime | yLOA; -- cgit v1.2.3