0

Can anyone tell me what is the return type of Math.rint() ?

Because in Google it is showing double but in my book it is showing int as return type

22nd Nov 2021, 4:54 PM
Atul
3 Answers
+ 3
Math.rint() returns double according to https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html Online docs are supposedly more updated than printed books.
22nd Nov 2021, 7:05 PM
Ipang
+ 3
Hello Atul Math.rint() returns double. https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Math.html#rint(double) You can also test it if you just try to assign it to an integer. int x = Math.rint(2.3);
22nd Nov 2021, 7:12 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
Thank you all
23rd Nov 2021, 11:49 AM
Atul