package net.flyfkue.base.math;
import java.math.BigInteger;
import net.flyfkue.base.log.Log;
public class BiTest {
public static void main(String[] args) {
System.out.println("beg!");
BiTest b = new BiTest();
// b.run1();
b.run2();
}
public void run2() {
run2_1(0, 1000, -1);
Log.d("++++++++");
run2_1(4294967397L, 1000, -1);
Log.d("++++++++");
run2_1(4294967397L, 1000, 1);
}
public void run2_1(long ll, int step, int presignnum) {
BigInteger bi;
long oldll = ll;
if (presignnum == 1) {
ll -= step;
bi = new BigInteger(ll + "");
} else if (presignnum == -1) {
ll += step;
bi = new BigInteger(ll + "");
} else { // ==0
step = 0;
Log.d("result:", ll, step, new BigInteger(oldll + "").intValue(), presignnum);
return;
}
Log.d("o", oldll, step, new BigInteger(oldll + "").intValue(), presignnum);
int thissignnum;
if (bi.intValue() > 1) {
thissignnum = 1;
if (presignnum == -1) {
step = step / 2;
}
} else if (bi.intValue() < 1) {
thissignnum = -1;
if (presignnum == 1) {
step = step / 2;
}
} else {
thissignnum = 0;
}
Log.d("n", ll, step, bi.intValue(), thissignnum);
run2_1(ll, step, thissignnum);
}
public void run1() {
Log.d(Integer.MIN_VALUE, Integer.MAX_VALUE);
long minus = Long.valueOf(Integer.MAX_VALUE) - Integer.MIN_VALUE;
Log.d(minus);
int cnt = 0;
int num = 0;
for (long i = minus - 2; i < Long.MAX_VALUE; i++) {
BigInteger bi = new BigInteger(i + "");
if (bi.intValue() == 1) {
// 1,a, 1
// 4294967297,a, 1
Log.d(i, bi.intValue());
cnt++;
}
// i += 1000;
if (num++ > 10000000) {
Log.d(i, bi.intValue());
num = 0;
}
}
}
}