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);
	}

}

Open in new window


i got out put
d is34440.0


can i represent positive exponential as below?
d=34444+04;//exponential notation

please advise
LVL 7
gudii9Asked:
Who is Participating?
 
ozoCommented:
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;
or start with a float
float f3 = 34444e-04f;
0
 
gudii9Author 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);
	}

}

Open in new window


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);
	}

}

Open in new window

0
 
ozoCommented:
34444e+04 is 3.4444E8
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
ozoCommented:
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
 
gudii9Author 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.

please advise
0
 
ozoCommented:
+ 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
 
gudii9Author Commented:
d=34444-04;//subtraction notation

what it mean by subtraction notation
why it gave output
d is34440.0
0
 
ozoCommented:
Subtracting four from thirty-four thousand four hundred forty-four leaves thirty-four thousand four hundred forty
0
 
gudii9Author Commented:
oh
0
 
gudii9Author 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));

	}

}

Open in new window


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

Open in new window


how it exponential operator different from addition or subtraction. please advise
0
 
gudii9Author Commented:
what it mean by "double exponentioal notation"
0
 
gudii9Author 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));

	}

}

Open in new window



i got output as
d is34440.0
d1 is34448.0
f is3.4444
d==f isfalse
d3 is 3.4444000000000000
d==f isfalse

Open in new window

0
 
gudii9Author 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

please advise
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.