Page 1 of 1
[Implemented] bit-wise enumerations.
Posted: Sat Dec 01, 2012 5:56 pm
by jassing
I frequently use constants for bit-enumeration (1,2,4,8,16,32,64,128 etc) It would be nice if there was an enumeration form that automatically incremented by doubling vs. adding 1.
Re: bit-wise enumerations.
Posted: Sat Dec 01, 2012 9:52 pm
by luis
Can't you just use a macro ?
Code: Select all
Macro POW2
(#PB_Compiler_EnumerationValue - 1) << 1
EndMacro
Enumeration
#ONE = 1
#TWO = POW2
#THREE = POW2
#FOUR = POW2
#FIVE = POW2
#SIX = POW2
EndEnumeration
Debug #ONE
Debug #TWO
Debug #THREE
Debug #FOUR
Debug #FIVE
Debug #SIX