# double exponentioal notation

hi, i am trying below pogram
``````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

LVL 7
###### Who is Participating?

Commented:
testing.java:18: error: incompatible types: possible lossy conversion from double to float
a double approximates  3.4444 as
3.4443999999999999062083588796667754650115966796875
a float approximates  3.4444 as
3.4444000720977783203125
you can explicitly convert
float f3 = (float)34444e-04;
float f3 = 34444e-04f;
0

Author Commented:
``````public class test {

/**
* @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);
}

}
``````

why above gives compile error.

below why giving false.

``````public class test {

/**
* @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);
}

}
``````
0

Commented:
34444e+04 is 3.4444E8
0

Commented:
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
0

Author Commented:
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.

0

Commented:
+ 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));
0

Author Commented:
d=34444-04;//subtraction notation

what it mean by subtraction notation
why it gave output
d is34440.0
0

Commented:
Subtracting four from thirty-four thousand four hundred forty-four leaves thirty-four thousand four hundred forty
0

Author Commented:
oh
0

Author Commented:
``````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
``````

0

Author Commented:
what it mean by "double exponentioal notation"
0

Author Commented:
``````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
``````
0

Author Commented:
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