• 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

Range for Long

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the range for long. I know long can hold 64 bits. Using the formula -2^bits-1 to (2^bits-1)-1 and using the calculator I calculate the range to be:
-9223372036854775808 to 9223372036854775808

But on compile it says that this is out of range. Could someone please give me the correct range for long and let me know what is wrong here.

Many thanks,
Fes D Gaur
 
Fes D Gaur
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gadzooks! I figured it out. I have to have L after or l after the number. Then it works. I guess just like any floating point number is automatically assumed to be double and to change it to float an f or F is needed in the same way to take on a number larger than the integer range and to put it into a long type variable the L is needed at the end of the literal.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic