javascript - Decimal number gets disapper -


my code:

var $label = $(ev.currenttarget); var $price = $label.parent("form").find(".oe_price .oe_currency_value");  if (!$price.data("price")) {     $price.data("price", parsefloat($price.text());   //price 10.30 returns 10.3 number }  $price.html($price.data("price")+parsefloat($label.find(".badge span").text() || 0)); /* value coming in **badge** **12.00**  * parsefloat converts **12**  * thats why after addition got output **22.3**  * want **22.30**  */ 

i have string

'10.30'

now, if convert string number using parsefloat

parsefloat('10.30')

i got output 10.3

and if using .tofixed(2)

parsefloat('10.30').tofixed(2)

i got output 10.30 in string big problem me because want output number.

and if this

number(parsefloat('10.30').tofixed(2))

i got output 10.3

but want output in number , decimal point 10.30

plz help...!!!

try this:

parsefloat(math.round(num3 * 100) / 100).tofixed(2); 

see live demo


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -