The body of the function set_bit(uint64_tx, int pos, bool value)
which returns the modified value of the input x
, where the bit at the pos position is replaced with the value value.
Remember that in the C language (this is defined in stdbool.h), true is the integer 1 while false is the integer 0.
Code
uint8_t a=0b00000000;
uint8_t b=0b00001000;
uint8_t c=0b11111101;
uint8_t d=0b11011011;
// l'opération ~( a ) renvoi 0b11111111
// l'opération (c & a) renvoi 0b00000000
// l'opération (c & b) renvoi 0b00001000
// l'opération (a | b) renvoi 0b00001000
// l'opération (d & c) renvoi 0b11011001
#include <stdint.h>
#include <stdbool.h>
/*
* @pre 0<= pos < 64
*/
uint64_t set_bit(uint64_t x, int pos, bool value)
{
// à compléter
}