| Author |
why does this compile?
|
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
how is (f<c) even compiling? arent they of different types?
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
is this because in an arithmetic operation the char will be promoted to float? i think this could be the reason...
please confirm
|
 |
rohan yadav
Ranch Hand
Joined: Oct 13, 2009
Posts: 156
|
|
|
I think char is internally converted to float or int.
|
Sage of The Monstrous Toad of Mount Myoboku
|
 |
Chintan B Shah
Ranch Hand
Joined: Sep 23, 2008
Posts: 83
|
|
I think "widening" happens here and "if" boolean expression would look something like this
if(9<97)
My 2 cents.
Thanks
Chintan.
|
SCJA 1.0
|
 |
Hiruka Sandev
Greenhorn
Joined: Nov 22, 2009
Posts: 11
|
|
|
Internally a char is a 16 bit unsigned integer. So a char can be used in places where a integer literal could be used.
|
 |
Dejan Miler
Ranch Hand
Joined: Nov 14, 2009
Posts: 56
|
|
First of all char is of integer type.
And secondly i agree with Ankur char will be promoted to float.
Dejan.
|
SCJP 1.6 in progress ....
|
 |
 |
|
|
subject: why does this compile?
|
|
|