Math.round(argument)
returns a number that is rounded from the argument.
In your example you ignore the returned value.
You probably meant to write:
odleglosc = Math.round(odleglosc);
x = Math.round(x);
Otherwise if you just write Math.round(x);
Java will make the calculation and have no variable to assign it to, and gets thrown away.
Math.round()
does not modify your variable because a double
the value is passed to the function (compare all-by-value vs call-by-reference).
To round your value use
a = Math.round(a);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.