Bit management in a word
Solved
PerkyPlatipus
-
PerkyPlatipus -
PerkyPlatipus -
Bonjour,
I have a variable toto that is 16 bits.
According to several conditions, the bits need to be set to 1.
But I don't know how to do that. (structured program)
Let me explain:
If I have titi and tata, then bit 4 should be set to 1.
If I have popo or papa, then bit 7 should be set to 1.
Etc...
However, I can have "popo or papa" and "titi and tata" at the same time, meaning both bit 4 and bit 7 can be set to 1 simultaneously and that is my problem.
If I only had one bit, I could say:
if titi and tata then toto:= 8...
I hope I've been clear :/
Thank you in advance.
I have a variable toto that is 16 bits.
According to several conditions, the bits need to be set to 1.
But I don't know how to do that. (structured program)
Let me explain:
If I have titi and tata, then bit 4 should be set to 1.
If I have popo or papa, then bit 7 should be set to 1.
Etc...
However, I can have "popo or papa" and "titi and tata" at the same time, meaning both bit 4 and bit 7 can be set to 1 simultaneously and that is my problem.
If I only had one bit, I could say:
if titi and tata then toto:= 8...
I hope I've been clear :/
Thank you in advance.
1 answer
-
yg_be Posted messages 23437 Registration date Status Contributor Last intervention Ambassadeur 1 588
Hello, what is the problem with changing bits 4 & 7, either simultaneously or one after the other?
What do you intend to do viatoto:= 8
?