Created
November 21, 2009 23:03
-
-
Save krestenkrab/240327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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