• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BYTE increment

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When u incremnt a byte does it get convered to an int;
for eg
byte a;
a++;
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it does:


For more info, check out the spec.
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm pretty sure there's no implicit casting going on here. If you continue the loop, you'll see that value of b never exceeds the value of a signed byte, merely that the sign changes. So unless I misunderstand what's going on (some one please correct me if I am), I believe that no, there is no casting going on and that doing an increment (or decrement) operation on a byte does not implicitly change the byte to an int.

Also, I read the spec Daniel Moore posted, and I was unable to find where it mentions implicit casting in the increment operator. Could someone please point me in the right direction?
[ August 24, 2004: Message edited by: Jason Fox ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe incrementing byte (byte b with increment operator (b++
does not convert it to int but by explicitly adding 1 to byte will convert it to int (b = b+1 .
 
Nikhilesh Fonseca
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx guys!!
Jason Fox ,shilpa challa ,Daniel Moore
I tried something like the code which Daniel wrote .Silly of me not to try it out earlier.at 127 of the increment operation it gets rounded to-128 and again at -1 to 0.So i guess it still remains a Byte.
So thanx u all
Nikhilesh
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic