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 MATH Problem - Shor.MIN_VALUE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "MATH Problem - Shor.MIN_VALUE" Watch "MATH Problem - Shor.MIN_VALUE" New topic
Author

MATH Problem - Shor.MIN_VALUE

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
From web page


output:

Positive
infinity
NaN
Integer.MIN_VALUE
Long.MIN_VALUE
Positive zero

Why not Short_MIN_VALUE?

I have executed the below pgm and I got the output for abs(Short.MIN_VALUE)



output:
Infinity
Infinity
NaN
128
32768
-2147483648
4.9E-324
23


Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Thanks for referencing Dan's question, it is always good to see the original question.
Well, Short.MIN_VALUE is -32768 is a short and that's converted to an int value of -32768. Then the int Math.abs(int) method is called on -32768 returning an int value 32768, and that's not Short.MIN_VALUE. That is, Math.abs only returns an int, long, float, or double. It does not return a short.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MATH Problem - Shor.MIN_VALUE