In C, I have a variable of the type uint64 (x) and a variable of type int (i). I need to change the MSB of x to the value of i (which will vary). How can I achieve that. Please help!
int i;
//
.. some code here that will set i to 0 or to 1.
//
uint64_t x = 0xbeefcafebabecab1;
The binary representation of x is: 1011111011101111110010101111111010111010101111101100101010110001. I need to change the MSB (the leftmost 1 in this case) to the current value of i (say one or zero) How can i achieve that? I have some ideas but i'm getting more confused. Any suggestions will be really helpful.