Skip to content

Instantly share code, notes, and snippets.

@krestenkrab
Created November 21, 2009 23:03
Show Gist options
  • Save krestenkrab/240327 to your computer and use it in GitHub Desktop.
Save krestenkrab/240327 to your computer and use it in GitHub Desktop.
// Representation of int32
class EInt32 extends EObject {
static final long MIN_INT = Integer.MIN_VALUE, MAX_LONG=Long.MAX_VALUE;
int value;
ENumber plus(EObject rhs) { return rhs.r_plus(value); }
ENumber r_plus(int lhs) {
long ret = lhs + this.value;
if(((ret + MIN_INT) & MAX_LONG) <= 0xFFFFFFFFL)
return new EInt32((int)ret);
else
return new EBig(ret);
}
// and others ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment