+ 11
How to round a double [Solved]
I've already use Math.Round() but still didn't work https://code.sololearn.com/cB4ArxM88EoV/?ref=app
5 Antworten
+ 3
I think that it Math.Round does not change the value of the variable but instead returns the rounded value
+ 7
Benzar Gian Rosales You were right, how stupid i am.
+ 5
public class rounding {
public static void main(String[ ] args) {
double a = 12.765;
int b = (int) Math.round(a);
System.out.println(b);
}}
This is the Syntax used to round a double into an Integer , then printing the rounded value on the screen ; Actually in this piece of code we ae casting the Double value into an Integer by using Math class to round it .
- 1
hi