rendered paste body public static DevInt pow(DevInt x, DevInt p) {
if (p == 1) {
return x;
}
if (p <= 0) {
return new DevInt(0);
}
DevInt [] tmp = p / 2;ftsefsdfsdfsdfsd
if (tmp[1] == 0) {
return pow(x * x, tmp[0]);
}
else if (tmp[1] == 1) {
return x * pow(x * x, tmp[0] );
}
return new DevInt();
}
// code gives floor(n^(1/root)).
public static DevInt root(DevInt number, DevInt root) {
if (number == 0) return 0;
Console.Write("-");
DevInt low = DevInt.root(DevInt.rightShift(number,root), root) << 1;
DevInt high = low + 1;
Console.Write(".");
return DevInt.pow(high, root) > number ? low : high;
}
public static int compare(DevInt o1, DevInt o2) {
// o1 > o2 = 1
// o1 == o2 = 0
// o1 < o2 = -1
if (o1.Length > o2.Length) { return 1; }
else if (o2.Length > o1.Length) { return -1; }
for (int i = (int)o1.Length; i >= 0; i--) {
if (o1[i] > o2[i]) { return 1; }
if (o1[i] < o2[i]) { return -1; }
}
return 0;
}
public static DevInt operator *(DevInt operand1, DevInt operand2) {
DevInt tmp = new DevInt();
DevInt shifter = new DevInt(operand2);
byte[] set = operand1.getBytes();
for (int i = 0; i <= operand1.Length - 1; i++) {
// Unrolled loop
if (i != 0) { shifter = shifter << 1; }
if ((byte)(set[i] | 0xFE) == 0xFF) { tmp = tmp + shifter; }
shifter = shifter << 1;
if ((byte)(set[i] | 0xFD) == 0xFF) { tmp = tmp + shifter; }
shifter = shifter << 1;
if ((byte)(set[i] | 0xFB) == 0xFF) { tmp = tmp + shifter; }
shifter = shifter << 1;
if ((byte)(set[i] | 0xF7) == 0xFF) { tmp = tmp + shifter; }
shifter = shifter << 1;
if ((byte)(set[i] | 0xEF) == 0xFF) { tmp = tmp + shifter; }
shifter = shifter << 1;
if ((byte)(set[i] | 0xDF) == 0xFF) { tmp = tmp + shifter; }
shifter = shifter << 1;
if ((byte)(set[i] | 0xBF) == 0xFF) { tmp = tmp + shifter; }
shifter = shifter << 1;
if ((byte)(set[i] | 0x7F) == 0xFF) { tmp = tmp + shifter; }
}
return tmp;
}