Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
Then it would have been better, imo, to put 1 2 4 8 etc...
Event the great fysiks was confused :mrgreen: |
Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
Quote:
|
Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
Yesn enum works like this, take last value and apply the supplied ( +1 if not specified) operation.
That's why in that specific case ( <<=1 ), if you don't initialiaze first value to 1, then it's 0 and you 0<<1 == 0 so it can't work. |
Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
Excuse my stupid question ...
I know that with the operator | can i increase bitsums values such as (1 <<1) | (1 <<2) Exist another operator but to do the opposite of the operator |?, is say, to decreased bitsums? Thanks all, and excuse my english. PS: Thanks for the tut bugsy:) |
Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
Quote:
See the Common bit-field operations section. Both are right next to eachother. |
Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
Connor, IMO, it is better to show the enum values as the value of one with a respective left shift since thats how bit sums are referred to throughout the tut. I do understand where you are coming from though and will add the respective X << 1 shift as well as keep what I have now.
Zezima, that is explained above, you use var &= ~( 1 << 2 ) |
Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
Quote:
if i wanna decreased 8 - 1 with bitsums, how can i make this ? :p Result |= ( 1 << 3 ) & ~( 1 << 0 ) |
Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
Quote:
|
Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
8 = 1 << 3
1 = 1 << 0 8 = 1000 1 = 0001 7 = 1 << 0 | 1 << 1 | 1 << 2 7 = 0111 You could get 7 by doing ~8 but each situation will be different. You can't do addition or substation by 1 like that if thats what youre trying to do |
Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
8-1 :|
|
All times are GMT -4. The time now is 23:02. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.