Explain the working of the snippet | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Explain the working of the snippet

System.out.println((byte) (417)); It outputs -95. Explain the calculations

7th Jul 2020, 5:52 AM
Ayush Pandey
Ayush Pandey - avatar
7 Answers
+ 2
Ipang waiting for ur answer
7th Jul 2020, 3:09 PM
Ayush Pandey
Ayush Pandey - avatar
+ 2
Ayush Pandey You changed the Description. I suspect that happens because 417 is out of data range of 'byte' which is around -128 ~ 127. That might be an effect of value overflow, but I'm not sure I can explain. This article covers overflow effect of `int` type, but I suppose the same thing can happen with `byte`. https://dzone.com/articles/overflow-and-underflow-data
7th Jul 2020, 4:00 PM
Ipang
+ 1
How does it evaluate to -95
7th Jul 2020, 6:32 AM
Ayush Pandey
Ayush Pandey - avatar
0
Ayush Pandey That line does not even compile bro! Are you sure that is the complete code? or did you just write a portion of it?
7th Jul 2020, 6:09 AM
Ipang
0
Yeah I know you code man Don't get upset too quick though I didn't say you don't know the A's But that line, as it is, just trigger error That's all I'm saying ... lol
7th Jul 2020, 6:20 AM
Ipang
0
Danijel Ivanović May u explain me
28th Jul 2020, 5:45 AM
Ayush Pandey
Ayush Pandey - avatar
- 2
Ipang lol.... what do you think I dont even know The "A's " of coding.... anyways actually I wrote in the title that it is snippet which actually means a portion of whole code.... So actually I want to know the working of this piece.... For I know how to write codes XD
7th Jul 2020, 6:17 AM
Ayush Pandey
Ayush Pandey - avatar