Hacker News new | ask | show | jobs
by tveita 3940 days ago
Java's Math.pow accepts non-integer exponents so your example doesn't handle all cases.
1 comments

Right, it only works on positive integers, but my original example using exp and ln works in nearly all cases (though you probably want to do some rounding in the case of an integer input). That's actually another point in its favor. It's constant time and handles the odd cases.