Message7661
This appears to be because of java.math.BigInteger().toString(16)
The following code
// -=-=-=-=-=-=-=-=-=-=-=-=-=-
import java.math.BigInteger;
import java.util.Random;
public class BigIntTest {
public static void main (String args[]) {
String numString = "1";
for (int power = 1 ; power < 23 ; power++) {
BigInteger b = new BigInteger(numString);
long start = System.currentTimeMillis();
String s = b.toString(16);
System.out.println(power+"("+numString.length()+" digits): took " + ((System.currentTimeMillis() - start)/1000) + " seconds");
numString = numString + numString;
}
}
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-
Outputs the following (I didn't let the code finish, it was taking too long)
1(1 digits): took 0 seconds
2(2 digits): took 0 seconds
3(4 digits): took 0 seconds
4(8 digits): took 0 seconds
5(16 digits): took 0 seconds
6(32 digits): took 0 seconds
7(64 digits): took 0 seconds
8(128 digits): took 0 seconds
9(256 digits): took 0 seconds
10(512 digits): took 0 seconds
11(1024 digits): took 0 seconds
12(2048 digits): took 0 seconds
13(4096 digits): took 0 seconds
14(8192 digits): took 0 seconds
15(16384 digits): took 0 seconds
16(32768 digits): took 0 seconds
17(65536 digits): took 2 seconds
18(131072 digits): took 9 seconds
19(262144 digits): took 37 seconds
20(524288 digits): took 150 seconds |
|
Date |
User |
Action |
Args |
2013-02-11 03:57:04 | amak | set | messageid: <1360555024.34.0.890519505895.issue2013@psf.upfronthosting.co.za> |
2013-02-11 03:57:04 | amak | set | recipients:
+ amak |
2013-02-11 03:57:04 | amak | link | issue2013 messages |
2013-02-11 03:57:04 | amak | create | |
|