Rounding with Math.round
What is the syntax for using Math.round?
i.e.: is this right (if rounding to 2 decimal places)?
double decimal = Math.round((100*(4/3))/100.0);
and would this work?:
int places = 2;
int roundInt = (int)Math.pow(10, n);
double roundDouble = Math.pow(10, n);
double fraction = Math.round((roundInt * (4 / 3)) / roundDouble);
[385 byte] By [
sonyvaioa] at [2007-10-1 2:21:13]

This is kind of a dilemma. Earlier today you wrote this in another thread:
"As much as your "advice" helps, the java docs provide only methods for the BigDecimal/Integer objects. They don't show complete syntax, and don't contain examples. Fortunately, I have avoided the "35-years-old-and-still-living-in-my-mother's-basement-and-aren't-even-professi onal-programmers" path and have enough of a life that I try not to spend all day reading about Java syntax."
Now, the answer to your question can be found in the javadocs. But if I tell you the answer, that will imply that I am a "35-years-old-and-still-living-in-my-mother's-basement-and-aren't-even-professi onal-programmers" and there's no way I would admit to that in public. So sorry, can't help you.
try thisdouble result = Math.round(value * Math.pow(10, (double) decimals)) / Math.pow(10, (double) decimals);where the variable value stores the value you want to round offand decimals store the no of decimal points