Friday, February 3, 2012

scientific notation in c++

scientific notation in c++ 

Scientific notation is a useful shorthand for writing lengthy numbers in a concise manner. In scientific notation, a number has two parts: the significand, and a power of 10 called an exponent. The letter ‘e’ or ‘E’ is used to separate the two parts. Thus, a number such as 5e2 is equivalent to 5 * 10^2, or 500. The number 5e-2 is equivalent to 5 * 10^-2, or 0.05.

In fact, we can use scientific notation to assign values to floating point variables. 

double dValue1 = 500.0;
double dValue2 = 5e2; // another way to assign 500

double dValue3 = 0.05;
double dValue4 = 5e-2; // another way to assign 0.05

Example:

No comments:

Post a Comment