var  aTens = [ "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY"];
var aOnes = [ "ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE",
"TEN", "ELEVEN", "TWELVE", "THIRTEEN", "FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN",
"NINETEEN" ]; function ConvertToHundreds(num)
{
var cNum, nNum;
var cWords = ""; num %= 1000;
if (num > 99) {
/* Hundreds. */
cNum = String(num);
nNum = Number(cNum.charAt(0));
cWords += aOnes[nNum] + " HUNDRED";
num %= 100;
if (num > 0)
cWords += " AND "
} if (num > 19) {
/* Tens. */
cNum = String(num);
nNum = Number(cNum.charAt(0));
cWords += aTens[nNum - 2];
num %= 10;
if (num > 0)
cWords += " ";
} if (num > 0) {
/* Ones and teens. */
nNum = Math.floor(num);
cWords += aOnes[nNum];
} return cWords;
} function ConvertToWords(num)
{
var aUnits = [ "THOUSAND", "MILLION", "BILLION", "TRILLION", "QUADRILLION" ];
var cWords = (num >= 1 && num < 2) ? "" : "";
var nLeft = Math.floor(num);
for (var i = 0; nLeft > 0; i++) {
if (nLeft % 1000 > 0) {
if (i != 0)
cWords = ConvertToHundreds(nLeft) + " " + aUnits[i - 1] + " " + cWords;
else
cWords = ConvertToHundreds(nLeft) + " " + cWords;
}
nLeft = Math.floor(nLeft / 1000);
}
num = Math.round(num * 100) % 100;
if (num > 0)
cWords += ConvertToHundreds(num) + " CENTS ";
// else
// cWords += "Zero Cents"; return cWords+'ONLY';
} 调用:
ConvertToWords(123,450,000.66) -->ONE HUNDRED AND TWENTY THREE MILLION FOUR HUNDRED AND FIFTY THOUSAND SIXTY SIX CENTS ONLY

最新文章

  1. ie6并不是不支持!important
  2. Jquer的三种初始化方式
  3. 【英语】Bingo口语笔记(49) - 春节请客吃饭的表达
  4. Jquery实现页面上所有的checkbox只能选中一个
  5. POJ 3181 Dollar Dayz(高精度 动态规划)
  6. 来晚了--SALTSTACK要弄起
  7. mousewheel 与 DOMMouseScroll
  8. Coursera台大机器学习基础课程1
  9. EditText光标居上
  10. Eclipse EE遇到问题记录
  11. Python3 系列之 基础语法篇
  12. Windows10 Build 18298 桌面显示计算机(此电脑)
  13. 大学jsp实验七--JavaBean在JSP中的应用
  14. 上传程序Dictionary 字典 哈希--多读一写锁ReaderWriterLock
  15. [转]使用tee记录mysql client 所有的操作,十个节省时间的mysql命令
  16. Py中re.sub学习【转载】
  17. GE与POST方法区别
  18. String类型转json 转JSONObject 转 JSONArray 以及 遍历
  19. Linux每天一个命令:iperf
  20. dpkg: warning: files list file for package `*****&#39; missing, assuming package has no files currently installed解决办法

热门文章

  1. leetcode-algorithms-4 Median of Two Sorted Arrays
  2. postman系列之批量执行接口测试用例
  3. HashSet和ArrayList有什么区别
  4. 前端web的图标的样式
  5. NOIP2012国王游戏(60分题解)
  6. 深入浅出php socket编程
  7. Qt中漂亮的几款QSS
  8. PHP -S命令 PHP内置web服务器
  9. sql server 中进行除法运算时,如何得到结果是小数形式呢?
  10. OSI七层协议概念详解