Bit operation
#4

Код:
11111110111111111111111111111111
This is not the 8th bit.

If you try to "turn off" a specify bit, you can't do it with the OR logical operation because 1 OR 0 = 1 everytime.
You need to use AND logical operator with NOT.

PHP код:
main()
{
    new 
test_value 0b1111111111// there is 10, 1
    
test_value &= ~(<< 7); // 8-1
    
printf("%b"test_value);

Reply


Messages In This Thread
Bit operation - by RakeDW - 15.09.2018, 18:50
Re: Bit operation - by RakeDW - 17.09.2018, 15:24
Re: Bit operation - by Grim_ - 17.09.2018, 17:44
Re: Bit operation - by Dayrion - 17.09.2018, 17:51
Re: Bit operation - by NaS - 17.09.2018, 17:51
Re: Bit operation - by RakeDW - 17.09.2018, 21:12

Forum Jump:


Users browsing this thread: 1 Guest(s)