• 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

Long.MIN_VALUE

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public static void main(String s[]){
System.out.print((Long.MIN_VALUE < 0) + ","); //line 1
System.out.print((Double.MIN_VALUE < 0) + ","); //line 2
System.out.print(Double.MIN_VALUE < Long.MIN_VALUE);
}
What I understood from the previous posts was
Long.MIN_VALUE = 1000 .... 0000 (total bits 64)
Double.MIN_VALUE = 1000 .... 0000 (total bits 64)
Based on this line1 and line 2 should display false, why line1 displaying true?
Thanks
 
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suresh,
One mistake from my post in the earlier thread. :roll:
XXX would imply only the integer literals - read byte , short , integer & long -(I'm not sure of char )
The API is your best bud - yes , better than any of us.
Long.MIN_VALUE is some huge negative value of type long ( check JLS ) while Double.MIN_VALUE is the smallest positive value of type double ( check API )
HTH
Ashish H.
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suresh,
As Ashish has mentioned, the definitions of Long.MIN_VALUE and Double.MIN_VALUE are not the same. Long.MIN_VALUE represents the most negative long value. Double.MIN_VALUE represents the smallest positive double value.
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has come up at least three times in the three weeks that I've been contributing to JavaRanch. A raspberry to the Java class library developers who perpetuated this confusion by using the same symbol (MIN_VALUE) to mean very different things in different classes.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ron Newman:
This has come up at least three times in the three weeks that I've been contributing to JavaRanch. A raspberry to the Java class library developers who perpetuated this confusion by using the same symbol (MIN_VALUE) to mean very different things in different classes.


I agree. It should have been called SMALLEST_POS_VALUE.
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic