gudii9
asked on
double exponentioal notation
hi, i am trying below pogram
i got out put
d is34440.0
can i represent positive exponential as below?
d=34444+04;//exponential notation
please advise
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
exByte();
}
public static void exByte(){
double d=3.4444d;
d=34444-04;//exponential notation
System.out.println("d is"+d);
}
}
i got out put
d is34440.0
can i represent positive exponential as below?
d=34444+04;//exponential notation
please advise
34444e+04 is 3.4444E8
double d=3.4444d;
float f=3.4444f;
d=34444-04;//subtraction notation
System.out.println("d is"+d);
System.out.println("f is"+f);
System.out.println("d==f is"+ (d==f));
d=34444e-04;//exponential notation
System.out.format("d is %.16f\n",d);
System.out.format("f is %.16f\n",f);
System.out.println("d==f is"+ (d==f));
d is34440.0
f is3.4444
d==f isfalse
d is 3.4444000000000000
f is 3.4444000720977783
d==f isfalse
d is34440.0
d is3.4444E8
float f=3.4444f;
d=34444-04;//subtraction notation
System.out.println("d is"+d);
System.out.println("f is"+f);
System.out.println("d==f is"+ (d==f));
d=34444e-04;//exponential notation
System.out.format("d is %.16f\n",d);
System.out.format("f is %.16f\n",f);
System.out.println("d==f is"+ (d==f));
d is34440.0
f is3.4444
d==f isfalse
d is 3.4444000000000000
f is 3.4444000720977783
d==f isfalse
d is34440.0
d is3.4444E8
ASKER
public class test4 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
exByte();
}
public static void exByte(){
float f=3.4444f;
double d=3.4444d;
d=34444-04;//exponential notation
System.out.println("d is"+d);
System.out.println("d==f is"+ d==f);
System.out.println("d==f is"+ f==d);
}
}
both of above bolded lines giving error incomatible types even high precision double assigned to low precision float or vice versa.
please advise
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
exByte();
}
public static void exByte(){
float f=3.4444f;
double d=3.4444d;
d=34444-04;//exponential notation
System.out.println("d is"+d);
System.out.println("d==f is"+ d==f);
System.out.println("d==f is"+ f==d);
}
}
both of above bolded lines giving error incomatible types even high precision double assigned to low precision float or vice versa.
please advise
+ has precedence over ==, so "d==f is"+ d==f means ("d==f is"+ d)==f
Those lines should have been
System.out.println("d==f is"+ (d==f));
System.out.println("d==f is"+ (f==d));
Those lines should have been
System.out.println("d==f is"+ (d==f));
System.out.println("d==f is"+ (f==d));
ASKER
d=34444-04;//subtraction notation
what it mean by subtraction notation
why it gave output
d is34440.0
what it mean by subtraction notation
why it gave output
d is34440.0
Subtracting four from thirty-four thousand four hundred forty-four leaves thirty-four thousand four hundred forty
ASKER
oh
ASKER
public class testing {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double d=3.4444d;
double d1=3.4444d;
float f=3.4444f;
d=34444-04;//subtraction notation
d1=34444+04;
System.out.println("d is"+d);
System.out.println("d1 is"+d1);
System.out.println("f is"+f);
System.out.println("d==f is"+ (d==f));
d=34444e-04;//exponential notation
System.out.format("d is %.16f\n",d);
System.out.format("f is %.16f\n",f);
System.out.println("d==f is"+ (d==f));
}
}
above gives
d is34440.0
d1 is34448.0
f is3.4444
d==f isfalse
d is 3.4444000000000000
f is 3.4444000720977783
d==f isfalse
how it exponential operator different from addition or subtraction. please advise
ASKER
what it mean by "double exponentioal notation"
The exponential operator would be Math.exp or Math.pow http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#exp%28double%29 http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#pow%28double,%20double%29
Exponential (a.k.a. scientific) notation for float or double literals can be expressed using E or e
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
http://docstore.mik.ua/orelly/java-ent/jnut/ch02_04.htm#INDEX-196
Exponential (a.k.a. scientific) notation for float or double literals can be expressed using E or e
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
http://docstore.mik.ua/orelly/java-ent/jnut/ch02_04.htm#INDEX-196
ASKER
public class testing {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double d = 3.4444d;
double d1 = 3.4444d;
float f = 3.4444f;
d = 34444 - 04;//subtraction notation
d1 = 34444 + 04;
System.out.println("d is" + d);
System.out.println("d1 is" + d1);
System.out.println("f is" + f);
System.out.println("d==f is" + (d == f));
double d3 = 34444e-04;//exponential notation
//float f3 = 34444e-04;//exponential notation
System.out.format("d3 is %.16f\n", d3);
//System.out.format("f is %.16f\n", f3);
System.out.println("d==f is" + (d == f));
}
}
i got output as
d is34440.0
d1 is34448.0
f is3.4444
d==f isfalse
d3 is 3.4444000000000000
d==f isfalse
ASKER
double d3 = 34444e-04;//exponential notation
means like below right
d3=34444*(10 to the power of -4)
which is moving the decimal to left side 4 digits as below
d3 is 3.4444000000000000
i wonder why below line giving compilation error
//float f3 = 34444e-04;//exponential notation
please advise
means like below right
d3=34444*(10 to the power of -4)
which is moving the decimal to left side 4 digits as below
d3 is 3.4444000000000000
i wonder why below line giving compilation error
//float f3 = 34444e-04;//exponential notation
please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window
why above gives compile error.
below why giving false.
Open in new window