Posted 28 June 2013 - 12:24 PM
I use MineFactory's bundled wire to control something.I know the method to set the output of the wire.The method is "redstone.setBundledOutput(String side,int color)". color is a integer converted from binary number.For example:
Thus,I think i need to do some bit manipulation.
Example:
And how i can insure a specific digit is 0 or 1 ?
colors.white = 1 (decimal) = 0000000000000001(binary)
colors.orange = 2 (decimal) = 0000000000000010(binary)
So, if i need to turn both white and orange on ,i just input 1+2 to color.When i need to turn orange off,i let color minus 2.But,if i don't know the value of color first,a error may occur.For example,color is 1,and after minus it becomes -1.Thus,I think i need to do some bit manipulation.
Example:
value = 0100100000000010
if i want to turn off orange,i change value into
0100100000000000
so,my question is how to convert a decimal number into binary number?And how i can insure a specific digit is 0 or 1 ?