• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MATH Problem - Shor.MIN_VALUE

 
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic