aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Round Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Round" Watch "Round" New topic
Author

Round

Doit
Ranch Hand

Joined: Aug 03, 2000
Posts: 169

The output is -2147483648 . Could anyone please explain how?
- Thanks
[I added UBB CODE tags to your source code to make it more readable. Please try to use them in the future - Ajith]

[This message has been edited by Ajith Kallambella (edited August 31, 2000).]
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
round() method return int (if an input parameter is float), and -2147483648 is the minimal possible value for int variables.
(try System.out.println(Integer.MIN_VALUE); )

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Doit
Ranch Hand

Joined: Aug 03, 2000
Posts: 169
Hi,
How do u remember all these numbers? Do u have any notes or pointer where it is explained well?
like Math.ceil(Double.Max_Value)
Math.ceil(Double.NaN) etc
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
How do I remember all these numbers - good question! Actually it would be nice if I did not have to. Round() method could somehow warn us that input parameter is too big, uh? For what purpose did Java designers created all these exceptions, if they do not use them themselves?
When I started to work as a computer programmer, the basic rule was: �user will have either correct result or no result at all�. In your case round() method produces incorrect result. For me it is the worst decision, java designers could make. Maybe I am mistaken � Java experts, moderators, all you guys with CS Master degree, correct me!
I am afraid you have to have very good memory (loaded with tonns of small details) if you are going to pass the exam.
Notes: I have only this URL: http://www.geocities.com/SiliconValley/Network/3693/obj_sec9.html#obj28
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Round
 
Similar Threads
Math.round() method
Math function doubt
compilation error
Regarding Math.round()
Doubt in math.round