3

So I want to give JS a number in exponential notation. Amazingly, I haven't found a reference on how to do this.

Why doesn't this work?

 var tempdec = 8.85956e-8;

I don't have to do

 var tempdec = parseFloat('8.95956e-8');

...do I?

... answered below.

The upshot: It does work.

However, using var in the console returns undefined. But it works nonetheless.

Joshua Penman
  • 415
  • 1
  • 5
  • 13

1 Answers1

1

Numbers in javascript are floating point integers, so you don't have to use parseFloat('8.95956e-8') as 8.85956e-8 is same.

Try this in the console:

var tempdec = 8.85956e-8;
console.log(tempdec);//It logs 8.85956e-8 not undefined
console.log(parseFloat(tempdec));//Logs the same as above...
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231