Mohammed AL-khatib - 1 month ago 4x

C Question

What does 1.e0 mean in the following code

`product *=`

((1.e0-pow((double)2,i-32))*(1.e0-pow((double)2,i-32)))/(1.e0-pow((double)2,i-r));

It is c++ code, and how i can write 1.e0 in c#

Answer

```
<number>e<power> = <number> * 10^<power>
```

Where the power is a power of ten. Basically the number after `e`

tells you how many zeroes you have to append if it is positive. Negative powers make the number move by one digit to the right.

Examples

```
1.2e-3 = 1.2 * 10^-3 = 1.2 * 0.001 = 0.0012
1.2e-2 = 1.2 * 10^-2 = 1.2 * 0.01 = 0.012
1.2e-1 = 1.2 * 10^-1 = 1.2 * 0.1 = 0.12
1.2e0 = 1.2 * 10^0 = 1.2 * 1 = 1.2
1.2e1 = 1.2 * 10^1 = 1.2 * 10 = 12
1.2e2 = 1.2 * 10^2 = 1.2 * 100 = 120
1.2e3 = 1.2 * 10^3 = 1.2 * 1000 = 1200
```

You can see this notation on calculators. When the result is too large and would not fit into the display otherwise, the calculator automatically switches to the exponential notation.

In C# you would write the formula like this:

```
product *= (1 - Math.Pow(2, i - 32)) * (1 - Math.Pow(2, i - 32)) /
(1 - Math.Pow(2, i - r));
```

The conversions to `double`

happen automatically. One pair of parentheses is superfluous. One sub-expression occurs twice, you could write:

```
double temp = 1 - Math.Pow(2, i - 32);
product *= temp * temp / (1 - Math.Pow(2, i - r));
```

See: - Math.Pow Method (Double,â€‚Double) (msdn)

Source (Stackoverflow)

Comments