无为清净楼资源网 Design By www.qnjia.com
说明:
最近打算把 Js 练精点, 只好暂时放弃原来掌握的还行的 VBScript, 全面使用 Jscript/Javascript. 
发现 VBs 和 Js 都有些双方没有的功能...
比如 Js 就没有 VBs 的 formatNumber, formatN*** 类的函数. 
但是 Js 几乎随处可用 正则, 这是我的长处, 这点特吸引我, 不像 VBs 只有 RegExp 使用域可以使用正则.

引用一本书里的一句话:
The way to really learn a new programming language is to write programs with it.
--JavaScript: The Definitive Guide, 4th Edition

目录:
1. 内容: Number.prototype.formatNumber() 源代码.
2. 效率测试

shawl.qiu 
2006-10-14
http://blog.csdn.net/btbtd

1. 内容: Number.prototype.formatNumber() 源代码.

linenum 
复制代码 代码如下:
<%  
    var $num=9876577784321.011  
        Number.prototype.formatNumber=function(pointPsti){  
        /*--------------------------------------------------------*\    
         *    Javascript 格式化数字原型, By shawl.qiu  
         *    客户端使用: var $num=9876577784321.011; document.write('<br/>'+$num.formatNumber(3)+'<br/>');  
         *    服务端使用: var $num=9876577784321.011; Response.Write($num.formatNumber(3));   
        \*--------------------------------------------------------*/  
            if(this=='')return false;  
            if(typeof(pointPsti)=='undefined'){  
                var pointPsti=3;  
            } else { if(isNaN(pointPsti)){pointPsti=3}; }  
            var num=this+'', numDc='', temp='';  
            if(num.indexOf('.')>-1){ ptPs=num.indexOf('.'); numDc=num.substr(ptPs); num=num.substr(0,ptPs); }  
            for(var i=num.length-1; i>=0;temp+=num.substr(i,1), i--);  
            var re=new RegExp('(.{'+pointPsti+'})','g');  
                temp=temp.replace(re,'$1,'); num='';                  
            for(var i=temp.length-1; i>=0; num+=temp.substr(i,1), i--);  
                num=num.replace(/^\,|\,$/,'')+numDc;  
            return num; // shawl.qiu script  
        }  
            Response.Write($num.formatNumber(3)+'<br/>');  
%> 

2. 效率测试

输出 10,000 次, 耗时 2797 毫秒. 
输出 5,000 次, 耗时 1515 毫秒. 
输出 2,000 次, 耗时 672 毫秒. 
输出 1,000 次, 耗时 281 毫秒. 
输出 500 次, 耗时 140 毫秒. 
输出 100 次, 耗时 16 毫秒. 
标签:
js,prototype,格式化数字,By,shawl.qiu

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。