org.snapscript.tree.math.ByteCalculator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
package org.snapscript.tree.math;
import org.snapscript.core.Value;
import org.snapscript.core.ValueCache;
public class ByteCalculator extends IntegerCalculator {
@Override
public Value and(Number left, Number right) {
byte first = left.byteValue();
byte second = right.byteValue();
return ValueCache.getByte(first & second);
}
@Override
public Value or(Number left, Number right) {
byte first = left.byteValue();
byte second = right.byteValue();
return ValueCache.getByte(first | second);
}
@Override
public Value xor(Number left, Number right) {
byte first = left.byteValue();
byte second = right.byteValue();
return ValueCache.getByte(first ^ second);
}
}