Steven Steven - 8 months ago 31
Javascript Question

The Jquery displays $20.099999999999998 instead of $20.1

This is the Jquery code:

function Totalprice()
var unitprice=$('#unitpay').val();
var quota=$('#readers').val();
var totalprice=unitprice*quota;


When the value of readers is 67 and the unitpay is 0.3, it calculates the total price and displays $20.099999999999998 , not $20.1. What's wrong? If I want it to display $20.1 instead of $20.099999999999998, how can I rewrite the code?


How about this:




to show it as an actual dollar amount.