Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Exponential to Number.
12-14-2009, 05:48 AM #1
- Join Date
- Dec 2009
- Thanked 0 Times in 0 Posts
Exponential to Number.
When i am doing rounding of the value i am getting the o/p like 2.2e4.
I have to display this value in decimal value(2.0002) not in exponential.
Can any one please help me to resolve this issue.?
12-14-2009, 06:27 AM #2
Um...you apparently don't understand what 2.2e4 means.
2.2e4 is the same as 22000.0
2.2e-4 would be the same as 0.00022
I'm actually surprised that you would ever get "2.2e4". Are you sure it wasn't "2.2e-4"???
Anyway, you *can* control the display using toFixed( n ) where n is the number of digits to be shown after the decimal point.
var num = 2.2e4; alert( num.toFixed(2) ); // would show 22000.00 var num = 2.2e-4; alert( num.toFixed(2) ); // would show 0.00 -- because the 0.00022 "rounds" to just 0.00 var num = 2.2e-4; alert( num.toFixed(6) ); // would show 0.000220An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.