Jassing, seems that you've read this thread like I did

Demivec has posted the same solution as well, and I didn't find it...
I was posting one additional version which does not need an initial value (who ever will like this), and here are some of my (confusing) variants for different jobs...
Code: Select all
CompilerIf #PB_Compiler_Version>500
Macro Boolean(Expression)
Bool((Expression))
EndMacro
CompilerElse
Macro Boolean(Expression)
((Expression) Or #False)
EndMacro
CompilerEndIf
Macro BinaryEnumeration
;((#PB_Compiler_EnumerationValue-Boolean(#PB_Compiler_EnumerationValue>1))<<Boolean(#PB_Compiler_EnumerationValue>1)); [<=PB5: 0,1,2,4,8,...]
;((#PB_Compiler_EnumerationValue-1)<<1+((#PB_Compiler_EnumerationValue-2)&$8000000+(~-#PB_Compiler_EnumerationValue)&$8000000)>>27); [>PB5: 0,1,2,4,8,...]
(#PB_Compiler_EnumerationValue<<1-2+3*(((#PB_Compiler_EnumerationValue-1)&$8000000)>>27)); [>PB5: 1,2,4,8,16,...]
EndMacro
Enumeration
#ONE = BinaryEnumeration
#TWO = BinaryEnumeration
#THREE = BinaryEnumeration
#FOUR = BinaryEnumeration
#FIVE = BinaryEnumeration
#SIX = BinaryEnumeration
EndEnumeration
Debug #ONE
Debug #TWO
Debug #THREE
Debug #FOUR
Debug #FIVE
Debug #SIX