java - - Rounding a double up & removing the numbers after a decimal point - -
Can anyone tell me how I & amp; Then remove the numbers after the decimal places - & amp; Then convert this number to string?
For example, start with a double value of 55.6666666666667 - Make it round to double value of 56.0000000000 -
or start with 55.333333333333 - below the double value of 55.0000000000 -
& amp; Then delete the decimal point and convert it back to zero-string.
Thank you.
The best way to round a value for the nearest integer is: < Pre> If you want to do this in one line: You can read more about the int x = (int) math. (55.6666666666667);
x will be 56. To use
x a string at the end to round up or down, respectively, you
Math.ceil () and
Math.floor () For
String.valueOf () . Like this:
string xString = String.valueOf (x);
string xString = String.valueOf (Math Field (55.6666666666667));
Comments
Post a Comment