java - Printf E-notation -


for playing along @ home i'm reading absolute java 5th edition walter savitch (chapter 2 page 66).

the expression

double d = 12345.123456789; system.out.printf("start%12.5e end %n", d); 

the answer

start 1.23451e+04end 

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

as far e-notation go's meant scientific notation;

so 5.89e-4 mean 0.000589 (move decimal place if minus left if not move decimal place right).

the "e" "exponential".

in format expression:

the 12 (minimum) width of the displayed number presentation. 5 number of decimal places of precision.

the format scientific notation. number normalized between 1 , 10, , "+04" in printed expression power of 10 multiply number portion by.


Comments