-2

To cut to the chase, when performing some calculations within my code i have a result that is something like. 7.6742332E-30, i have this value stored in a double variable for example, double result = 7.6742332E-30;

When i later check whether this value is greater than 0 the result is true, that it is greater than 0, i assume due to the 7.6742332.

So my question is this, why is the E-30 not being considered and how do i resolve this?

Any advice would be great and thanks so much i advance!

  • 3
    7E-30 (or 7*10^-30) is (just) greater than zero, what did you expect? – Hans Kesting Mar 28 '13 at 13:20
  • 1
    You obviously don't know the [`E notation` aka `Scientific notation`](http://en.wikipedia.org/wiki/E_notation#E_notation). Basically, `Ex` is a shortcut for `* 10^x` (with x being a number). So `E-30` means `* 10^-30`, which is the same as `* 0.000000000000000000000000000001` (30 zeroes in front of the 1) – Nolonar Mar 28 '13 at 13:47

2 Answers2

11

7.6742332E-30 is 0.0000000000000000000000000000076742332, which is a positive number.

Michael Ross
  • 572
  • 4
  • 7
1

7.6742332E-30 mathematcally equals 7.6742332 x 10^-30 which is a positive number

Parimal Raj
  • 20,189
  • 9
  • 73
  • 110