Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

float variable

 
Brodie Patten
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there float variables in Java, and if so, what are they???
 
frank davis
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
32 bits, designated by F or f at end of literal : float x = 1.24F.
 
Brodie Patten
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aren't there also Real variable? What's the difference between Real and Float?
 
frank davis
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, there's Double which is 64 bits, and several integer types : int, short, long,byte, char.
 
Sri Bala
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add a point. By default, a number like 1.0 will be double in java. If you want a float. you have to specify 1.0f. so,
float f = 1.0; // will not compile
it should be
float f = 1.0f;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic