File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

round() returns ?

 
Paul Salerno
Ranch Hand
Posts: 172
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
round (double) < -- returns long
I was under the impression that methods of Math return either int or double.
Where am I wrong?
TIA
 
Matt Ghiold
Ranch Hand
Posts: 213
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the api, it states that the round method of the math class returns a long for a double and an int for a float hope this helps.
Matt
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point of the round() function is to convert a floating point value and return the closest integer value, so it doesn't makes sense to return a type double?
 
Nazmul Huda Sarkar
Ranch Hand
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paul
how come u have such umpression ? You should check the apis' again... :-)
Rajinder is perfectly right on your answer.
 
Jose Botella
Ranch Hand
Posts: 2120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not defending Paul because he sounds like a latin person , but he is right if he says that most of the methods in the Math class returns a double, apart from overloaded versions. round is the only method that doesn't do that.
Also most of the methods in the class Math take a double, apart from overloded ones. There is again one exception random that doesn't takes anything.
These knowledge was useful to me when taking the exam and it's easy to remember.
[ March 04, 2002: Message edited by: Jose Botella ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic