in javascript how to get only two decimal places?

Cases sum = parseFloat (8.99) + parseFloat (7.50);
Wait until the value is: 16.4900000002
How to get only two decimal places?

<script language="JScript">
Number.prototype.toFixed = function (num)
(
/ / Re-structure toFixed method, IE5.0 +
with (Math) this.NO = round (this.valueOf () * pow (10, num)) / pow (10, num);
return String (/ \. / g.exec (this.NO)? this.NO: this.NO +"."+ String (Math.pow (10, num)). substr (1, num));
)
alert ((12.9299). toFixed (2));
alert ((12.9999). toFixed (2));
</ script>

. toFixed (2) can not seem to rounding

分类:AJAX 时间:2009-08-16 人气:731
分享到:
blog comments powered by Disqus

相关文章

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.364 (s). 12 q(s)