• 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

float question

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear helper:
double d=12.5
float f=12.5

is syntax f=12.5 correct?

what is different between f=12.5 and d=12.5?
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ty lee:
Dear helper:
double d=12.5
float f=12.5

is syntax f=12.5 correct?

what is different between f=12.5 and d=12.5?


the floating point constants(Literals) in java are treated as doubles
so float f = 12.5 will give compile time error
u need to declare and intialise it as
float f=12.5f;
to specificaly tell compiler u want f to be intialised as a float.
hope this helps
 
ty lee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear vivekkumar sharma ,thank for helping
 
reply
    Bookmark Topic Watch Topic
  • New Topic