I have really interesting question. Recently I figured out, that Math.pow() takes only (double, double) args and I wonder why there is no overloaded functions with other types combinations such as (int, int) or (int, double) atc ...
I think this is big hole and paintfull weakness so I belive there is A REASON. Can anybody explain it to me, please?
Consider these two methods:
private int simplePow(int x) {
return x * x;
}
private int harderPow(int x) {
return (int) Math.pow(x, 2);
}
first one is much faster than second... problem is, that if you know, that you use power with (int, int), calculation is much effective and you don't need to take care of problems with double variables.