Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
こんにちは、次のことを行うための最良の方法を見つけようとしています
商品を 22.55 で販売するとします。GST は 10% = 2.25 ですが、次のように実行すると
変数合計 = (.10 * 22.55);
$2.250000002 を返します。実際のドルのみを表示するにはどうすればよいですか? $2.25
ありがとう
メソッドを使用できます.toFixed()。
.toFixed()
例
var val = 24.36257; val.toFixed(2)
24.36に戻ります
toFixedメソッドを試してください: http://www.w3schools.com/jsref/jsref_tofixed.asp
toFixed