• 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

Missing Numeric Suffixes

 
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why aren't there numeric suffices for byte, short or int? By numeric suffices I mean the letters that you attach to a number to coerce it into being a specific type of primitive literal (e.g. 2L to mean "2 as a long"). The lack of a numeric suffix for int kind of make sense as int is the default for integral numbers, but then consistency would seem to indicate that there wouldn't be one for double since double is the default for floating point literals. And why would byte and short be left out?

I'm not sure how important the answer to this question is to certification, but I'm wondering if there's something about the numeric primitives that I'm missing that would make the answer obvious.

Thanks,
Josh
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its because floating point literals (0.1, 122.32, etc...) are automatically considered as doubles, so float x = 0.1 would cause a compile time error, where as with bytes, shorts, chars, ints and longs, this would work with all of them - byte x = 1, short x = 1, etc..., its just the way the spec was written.
 
reply
    Bookmark Topic Watch Topic
  • New Topic