While bitwise operators are not important to me, if they existed I expect that I'd use them.
They're both fun and nice for simultaneously making things compact and legible.
int all_prefs = get_property("ThisScriptPrefs").to_int();
int drink_milk = 2;
int use_ode = 4;
int eat_cookie = 8;
boolean permission(int check_this) {
return to_boolean(all_prefs & check_this)
}
if(permission(eat_cookie)) {
if(permission(drink_milk))
use(1, $item[milk of magnesium]);
eat(1, $item[fortune cookie]);
}
int all_prefs = get_property("ThisScriptsPrefs").to_int();
int drink_milk = 2;
int use_ode = 4;
int eat_cookie = 8;
boolean permission(int check_this)
{
// returns true if ALL the bits in the bit mask are set
return (all_prefs & check_this) == check_this;
}
if ( permission(eat_cookie | drink_milk) )
use( 1, $item[milk of magnesium] );
Not in the base code. Nobody who does the code stuff cared enough to do it, and the sales pitch was insufficient to generate interest.
However, there's an ash script you can use that will add it in.
I am annoyed that the "^" operator already exists in ash to mean power. Does anybody really use it? I'd like to make power be "**", or, perhaps a function and use "^" for bitwise exclusive or. I'd also add "^=" in that case.Add some arithmetic bitwise operators:
a & b --> and
a | b --> or
~a -> not
a << b -> left shift
a >> b -> right shift
a &= b --> a = a & b
a |= b --> a = a | b
In all of the above, the operands must be integers; no coercion is allowed.
At least we only have one place to change.zlib. Damnit.
This just made me chuckling uncontrollably.And Zarqon just found himself a new forum signature![]()
Should that bea left shift
or is this some other Java quirk I totally don't grasp?a<< b -> left shift
Fortran.I don't like that way ** looks. It's more a typo. Is that used anywhere else?
You are looking at how the svn feed chose to display the svn log. The actual log is precisely as you suggested.Should that be ... or is this some other Java quirk I totally don't grasp?