File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ceil, floor... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "ceil, floor..." Watch "ceil, floor..." New topic
Author

ceil, floor...

sean cee
Ranch Hand

Joined: Oct 24, 2000
Posts: 115
Hi,
I thought Math.ceil and floor returns double NOT int.
but I came across couple of questions saying that it returns int.
I ran the code myself. it returns double..
Can someone confirm, please?
Thanks

Sean <br />SCJP2, SCJP2p1.4, SCWCD
Sudhir Bangera
Ranch Hand

Joined: Oct 10, 2000
Posts: 50
Hi Sean,
Sun's API documentation says that
ceil(double a) Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer.

floor(double a) Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.
http://java.sun.com/j2se/1.3/docs/api/index.html
Hence it should return double...
HTH....
Udayan Naik
Ranch Hand

Joined: Oct 18, 2000
Posts: 135
Hi Sean . The ceil and floor methods of Math class return INTEGRAL values as double values and not primitive type int.Thus if u say floor(13.2) it will return 13.0 , which is an integral value(13) converted to a double value , i.e 13.0.
I hope I have been clear enough.
------------------
Come on in !! Drinks are on the house in the Big Moose Saloon !!


Udayan Naik<BR>Sun Certified Programmer for the Java 2 Platform
sean cee
Ranch Hand

Joined: Oct 24, 2000
Posts: 115
Thanks guys..
So it won't return 13 . right? 13.0 instead...


 
 
subject: ceil, floor...
 
Threads others viewed
Math Class
K&B Math.round() question
Math.round(-4.5)=-4; Why?
sun sample mock q
simple or complicated?