Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert numbers into scientific notation?

I want to make a function that takes an entered value and converts it to scientific notation (N x 10^a)

I've tried many different things, but I can't seem to get it right.

Example:

I enter 200. The converter converts it to 2 x 10^2

like image 413
Samar Avatar asked Jun 20 '12 16:06

Samar


People also ask

What is the easiest way to do scientific notation?

Scientific notation is a way to make these numbers easier to work with. In scientific notation, you move the decimal place until you have a number between 1 and 10. Then you add a power of ten that tells how many places you moved the decimal. In scientific notation, 2,890,000,000 becomes 2.89 x 109.


1 Answers

You can do something like this:

a = 200 a.toExponential(); //output 2e+2 

fiddle: http://jsfiddle.net/Q8avJ/9/

like image 74
Hunter McMillen Avatar answered Oct 11 '22 19:10

Hunter McMillen