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 - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -