Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Widening

 
Ramm Kummar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




Edited by: bobz on 23-Mar-2009 08:33
 
Harshit Rastogi
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you cannot define i as float....
declare i as double instead of float
 
Campbell Ritchie
Sheriff
Pie
Posts: 49412
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want i as a float you have to provide a float literal

float i = 5f.
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That still wouldn't compile, because a float is wider than a long, and can't even be compared successfully against Integer.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49412
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Rob you are right. I hadn't noticed that bit. Passing incorrect argument types to a method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic