• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Comparison and equality operators

 
meeta verma
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never thought we could compare (>,<,== ,!=) an
int with a double
or
double with long
or
long with float etc.

I thought the primitives should be of the same type for comparison.

Can someone throw some light on this......
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are conversions that take place during the evaluation of the expression. "Widening", etc. The language specification talks about it in detail. But simply put, most things will be "widened" to the greater number of bits required and then the evaluation will take place.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic