• 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 Vs float/double?

 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is long narrower than float and double??

Sonir
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
  • byte = 8 bits
  • short = 16 bits
  • int = 32 bits
  • long = 64 bits
  • float = 32 bits
  • double = 64 bits

  • --Chris
    --Am I a Ranch Hand Yet
    [ January 09, 2002: Message edited by: Chris Graham ]
     
    Ranch Hand
    Posts: 2596
    Android Firefox Browser Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Yes!!!
    Though it may sound a bit strange, a long can be implicitly converted to float or doube. Of course, there's a loss of precision in it, but JLS says it is valid.
    HTH,
    - Manish
     
    Ranch Hand
    Posts: 44
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    i think they belong to different standards.
     
    Bartender
    Posts: 2205
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The logic behind the long->float promotion is that within a float, you can represent the order of magnitude of *every* possible long, although at the cost of some precision if you have a very big long.
    i.e, Long.MAX_VALUE = 9223372036854775807
    (float) Long.MAX_VALUE = 9.223372e18
    [ January 09, 2002: Message edited by: Rob Ross ]
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic