开发者

jQuery limit number of numbers after

开发者 https://www.devze.com 2023-01-27 14:06 出处:网络
Hi I am trying to work out the best way to do the following say I开发者_如何学Go sell an item for 22.55the GST on that is 10% which = 2.25

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

0

精彩评论

暂无评论...
验证码 换一张
取 消