I have an uint32\_t variable and I want to modify randombly the first 10 less significant bits(0-9) and then,still randomly, I want to modify bits from 10th to 23th. I wrote this simple program in C++ and it works for the first 10 bits but not for the others. I can't understand why 

```
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <iostream>
#include <math.h>

using namespace std;

void printuint(uint32_t value);

int main(){

    uint32_t initval=0xFFFFFFFF;
    uint32_t address;
    uint32_t value;
    uint32_t final;

    address=rand()%1024;
    address<<=23;
    printf("address \n");
    printuint(address);

    printf("final\n");
    final = (initval & address);
    printuint(final);

    return 0;
}

void printuint (uint32_t value){

    while (value) {
        printf("%d", value & 1);
        value >>= 1;
    }
    cout<<endl;
}

```

Adding this

```
    value = rand() % 16384;
    printuint(value);

```

and modifing `final = (initval & address) & value;`