# e-notation scientific notation

Hey all I asked this over at StackOverflow =) and I got a good answer but I still have no idea whats going on. I want to know how the expression got to the answer and maybe the math behind how it was reasoned.. the steps if you would be so kind. The likelihood is I don't understand the equation.

I'm not a big maths person please be gentle :p

For all those playing along at home I'm reading Absolute Java 5th Edition by Walter Savitch (Chapter 2 Page 66).

The Expression

double d = 12345.123456789;
System.out.printf("START%12.5e END %n", d);


START 1.23451e+04END


I understand the basic principles of this printf method's arguments for example I know the '%' represents the start of the parameters. '12' is the number of spacing, '.5' is the times the decimal point will move.... I see the decimal point has moved 4 places towards the left... can someone explain the principles of e-notation. Also how this expression came to this answer =).

As far as e-notation go's its meant to be scientific notation;

So like 5.89e-4 would mean 0.000589 (move the decimal place if minus left if not move the decimal place right).

• I believe the ".5" means "how many digits after the decimal point do you want displayed." – angryavian Jul 11 '13 at 14:22
• yes thanks blf that is correct =), however the more pressing matter is how the decimal point moved 4 places to the left ;p – BenniMcBeno Jul 11 '13 at 14:25
• Try a few cases and see what happens! With the same value of d, use format %12.1e and %12.2e and %12.3e and %12.4e ... Then use d=0.000589 and print it again with all those formats. – GEdgar Jul 11 '13 at 14:34

Used like this, eN (much more often EN) is just a symbol for $10^N$. It is used because scientific notation is convenient for large and small numbers and it avoids the need for superscripts. Superscripts used to be much more difficult to produce than they are today, and even today they are not easy in (some) word processors.
• No, the e+04 means multiply the displayed value by $10^4$. So $1.23451e+04=123.451e+02=12345.1$. If there are digits that don't fit, the number is rounded, but the e+04 doesn't tell you anything about them. If the true number were $1234512345.6789$ and you asked for 12.5e format you would get $1.23451e+09$. You would get the same if the true number were $1234510000$. The computer doesn't know how many places are correct-for floating point numbers it uses a constant number of bits. – Ross Millikan Jul 11 '13 at 15:37