Adds code to get the Scala REPL working

This commit is contained in:
Simon Ochsenreither
2013-01-30 04:21:11 +01:00
parent 0c5471d25e
commit b1eb4b9718
7 changed files with 213 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, Avian Contributors
/* Copyright (c) 2008-2013, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -94,6 +94,27 @@ public final class Integer extends Number implements Comparable<Integer> {
return (double) value;
}
public static int signum(int v) {
if (v == 0) return 0;
else if (v > 0) return 1;
else return -1;
}
// See http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
public static int bitCount(int v) {
v = v - ((v >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
public static int reverseBytes(int v) {
int byte3 = v >>> 24;
int byte2 = (v >>> 8) & 0xFF00;
int byte1 = (v << 8) & 0xFF00;
int byte0 = v << 24;
return (byte0 | byte1 | byte2 | byte3);
}
public static int parseInt(String s) {
return parseInt(s, 10);
}