I just made my first ever visual basic program to calculate these:
VB: (248 Or (6 - 1 - (intX) Mod 6))
C: (0xf8 | (6-1-(x % 6)))
I tried them with different values but couldn't notice any difference.
Quote:
What do "|=", "?" and "(byte)0 : (byte)1" do?
The following is from C++ Builders help:
In the expression E1 ? E2 : E3, E1 evaluates first. If its value is true, then E2 evaluates and E3 is ignored. If E1 evaluates to false, then E3 evaluates and E2 is ignored.
Example:
lcdValue = bitmap[x][y]!=0 ? 0 : 1;
If bitmap[x][y] is 0 then store 1 to lcdValue if bitmap[x][y] is something else store 0.
EDIT: I ignored the ! sign in the above explanation but I changed it now.
Then
lcdValue |= bitmap;
is same as
lcdValue = lcdValue | bitmap;
But then what this means ?
lcdValue |= bitmap[x][y]!=0 ? 0 : 1;
lcdValue <<= 1;
Below is lcdValue in different stages:
00000000 <- lcdValue in the beginning
00000001 <- 0 found from bitmap[x][y] -> inverted to 1-> ORred to lcdValue
00000010 <- left shift lcdValue with 1
00000011 <- 0 found from bitmap[x][y] -> inverted to 1-> ORred to lcdValue
00000110 <- left shift lcdValue with 1
00000110 <- 1 found from bitmap[x][y] -> inverted to 0-> ORred to lcdValue
00001100 <- left shift lcdValue with 1
Hope this makes some sense, teaching these to others just isn't my thing
