Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arithmetic promotion

 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



in line 1,found int ;required byte error is displaying.but i thought

How come found int;required byte error is coming .i just expected found Double,required byte.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the types of the operands are byte, both are promoted to int before the operation.
 
Dustin Johnson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K&B Book Pg. 182...

"...but more importantly, the result of an expression involving anything int-sized or smaller[i.e. byte] is always an int"

I believe the code is converting them both into int sized values automatically to try and perform the mathematical operation.
[ March 08, 2007: Message edited by: Dustin Johnson ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't ever write a program with variable names like that in your real working life. If you are not fired, leave immediately.
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic