> For the complete documentation index, see [llms.txt](https://valineliu.gitbook.io/deuterium-wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://valineliu.gitbook.io/deuterium-wiki/reading/cs-jing-dian-shu-ji/csapp-3e-homework-solution/2.-representing-and-manipulating-information/2.59-bit-expressions.md).

# 2.59 Bit Expressions

★★

**Problem**:

Write a C expression that will yield a word consisting of the least significant byte of `x` and the remaining bytes of `y`. For operands `x=0x89abcdef` and `y=0x76543210`, this would give `0x765432ef`.

expression：

```c
(x & 0xff) | (y & ~0xff)
```

test：

```c
#include <stdio.h>
#include <assert.h>

int main() {
    size_t mask = 0xff;
    size_t x = 0x89abcdef;
    size_t y = 0x76543210;
    size_t result = (x & mask) | (y & ~mask);
    assert(result==0x765432ef);
}
```

###
