Scientific Notation

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   hear noise   go to next page

Answer:

Of course, a leading minus sign is acceptable:

C:/temp>java DoubleDouble
Enter a double: -97.65
value: -97.65 twice value: -195.3

Scientific Notation

Scientific notation is another way of using characters to express a number. When it is converted to a double you get the same double that you would get with ordinary notation. In scientific notation, the letter E is used to mean "10 to the power of." For example, 1.314E+1  means  1.314 * 101  which is 13.14.

Scientific notation is merely a format used for input and output. The 64-bit pattern used for a double inside the computer are the same, no matter what character format was used for input. Here is an example:

C:/temp>java DoubleDouble
Enter a double: 1.234E+9
value: 1.234E9 twice value: 2.468E9

In this example, the user entered character data using scientific notation, and those characters were converted into a double. If the user had entered 1234000000, those characters would be converted into the same double. On output, scientific notation is used because the value is big, not because the input used scientific notation. The "E" may be upper or lower case:

C:/temp>java DoubleDouble
Enter a double: -7.001e-2
value: -0.07001 twice value: -0.14002

In this example, scientific notation was used with the characters that were read in. Those characters were converted to a double value. Some arithmetic was done with that value and the results were converted to characters and written out. Since the values were in the normal range of numbers, ordinary formats were used for the output characters.

QUESTION 5:

What is the meaning of 7.0E-2 ?