Search code examples
javamathdoublescientific-notation

what is the difference between Math.E and e


So if I run

System.out.println(1e+0);

it outputs 1

however if i run

System.out.println(Math.E);

it outputs 2.718.........

for the life of me I cant figure out how the little e interacts with numbers I get that Math.E is a constant that has something to do with logarithms but I thought the little e was just that being represented in a number yet the code is showing me something different. can anyone explain how that e interacts with numbers in java?


Solution

  • The literal 1e+0 is scientific notation for 1 * 10⁰, and 10⁰ being 1 this gives 1 * 1, thus 1.

    The constant Math.E is Euler's Number.