Hi I am trying to work out the best way to do the following
say I开发者_如何学Go sell an item for 22.55 the GST on that is 10% which = 2.25 However it seems when I run the following
var sum = (.10 * 22.55);
it returns $2.250000002 How do I make it so it only shows the real dollars? $2.25
Thanks
You can use the .toFixed()
method.
Example
var val = 24.36257;
val.toFixed(2)
will return 24.36
Try the toFixed
method: http://www.w3schools.com/jsref/jsref_tofixed.asp
精彩评论