pow

J2ME functions that aren't included - but should be

Because J2ME is annoying, it doesn't have a function that rounds a number, say 1234.56789 to a certain number of decimal places. So here is mine.

PS. I am learning Java, so if it doesn't adhere to the One True Java Way (tm), please feel free to write me a long, vitriolic diatribe criticising me and delete it before sending. Otherwise, leave a comment telling me where I went wrong.


public static double calumround(double arg, int places) {
double tmp = (double) arg * (pow(10,places));
int tmp1 = (int)Math.floor( tmp + 0.5 );

Syndicate content