0
What is the problem in this simple line of code????
In the following code, the compiler is returning conversion error when all of my variables are Integers.. int a,e,c,d; d=0 for(a=5;a>=0;a--) { e=c*(Math.pow(16,d)); d++ } System.out.println(e); https://code.sololearn.com/cV70J0S30JiY/?ref=app
9 ответов
+ 4
how did no one mention that most of the math operators produce a result of type double... so you have to do
e = c*(int)(Math.pow(16,d));
in order to type cast the math back to int bwfore you try storing it in int e, or you do
e = (int)(c*(Math.pow(16,d)));
+ 1
add at the very first
import java.Math
+ 1
kk thanx
+ 1
thank you....these ppl couldn't understand this thing for so long....I knw the basics..... anyways thanx again
0
it's showing lossy conversion from double to int...how????
0
you didnt assign value to c!
0
okay take c as 3....then?? It's showing the same thing
0
forgot to include math class
in this editor you have to add the classes for java
0
okay wait