• Post Reply Bookmark Topic Watch Topic
  • New Topic

Primitive casting  RSS feed

 
Vijay Gade
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

float a = 23.23f;
int b = a; //Fails to compile
int i = (int)a; //Compiles
------
int c = 123;
float d = c; //Compiles
------

My questions is, when both float and int are of size 32 bits, why the relation between float and int types is not symmetric?

Thanks,
-Vijay
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please continue this discussion under the cross-post in the beginner's forum. And please don't cross-post.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!