| Author |
why the code is giving the answer as -1
|
Vinay Belagavi
Greenhorn
Joined: Jun 15, 2006
Posts: 29
|
|
Hi, can anyone explain me why the below code is giving the answer as -1? public class DoubleDemo { public static void main(String[] args) { double d1=1.0; double d2=0.0; byte b=1; d1=d1/d2; b=(byte)d1; System.out.println(b); } }
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
Read my comments in the snippet below: Here's the byte code of your program: [ October 14, 2006: Message edited by: Barry Gaunt ]
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Vinay Belagavi
Greenhorn
Joined: Jun 15, 2006
Posts: 29
|
|
Thanks for the reply Barry.
|
 |
 |
|
|
subject: why the code is giving the answer as -1
|
|
|