• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Byte This !

 
Zac Roberts
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explain why I get a compiler error from the byte values but not from the int values:

Thanks-
Zac
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because in the statement
byte b2 = -b;
the b is promoted to an int because of the unary - sign, thus -b will be of type int which is not assignment compatible with a byte...
See 15.15.4 Unary Minus Operator -
[ February 18, 2002: Message edited by: Valentin Crettaz ]
 
Zac Roberts
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct sir... and by the way... are you going to have some sort of celebration when you hit 2000 posts, kindof like the millenium... maybe you could have some tequila to go along with the JavaRanch cowboy thing...
Zac
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll get myself some tequilaSSSS, don't worry
[ February 18, 2002: Message edited by: Valentin Crettaz ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic