math - float value extraction in javascript -


how can extract float value (0.9) whole integer value (9) in javascript?

example

var total = 67.9;  process  var whole var dec  var whole = 67; var dec = 9; 

the simplest way can think of this:

var string = total.tostring(); var dotidx = string.indexof("."); var dec = dotidx >= 0 ? +string.slice(dotidx + 1) : 0; 

notice doesn't work numbers in exponential forms.


Comments

Popular posts from this blog

php - Autoloader issue not returning Class -

java - How to put two numbers separated by a space into two different arrays -

python - matplotlib equivalent for Ubuntu servers with no GUI? -