/** 数字金额大写转换(可以处理整数,小数,负数) */
function smalltoBIG(n)
{
var fraction = ['角', '分'];
var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
var unit = [ ['元', '万', '亿'], ['', '拾', '佰', '仟'] ];
var head = n <? '欠': '';
n = Math.abs(n); var s = ''; for (var i = 0; i < fraction.length; i++)
{
s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
}
s = s || '整';
n = Math.floor(n); for (var i = 0; i < unit[0].length && n > 0; i++)
{
var p = '';
for (var j = 0; j < unit[1].length && n > 0; j++)
{
p = digit[n % 10] + unit[1][j] + p;
n = Math.floor(n / 10);
}
s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
}
return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整');
}

JS将人民币小写金额转换为大写的更多相关文章

  1. js 人民币小写金额转换为大写

    function smalltoBIG(n) { var fraction = ['角', '分']; var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', ...

  2. C#:小写金额转换为大写

    #region 小写金额转换为大写 public static string CurrToChnNum(double Currnum) { string sResult = ""; ...

  3. JS实现将数字金额转换为大写人民币汉字

    function convertCurrency(money) { //汉字的数字 var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', ...

  4. java将小写金额转换为大写的工具类

    public class Tool {             private static final String UNIT = "万千佰拾亿千佰拾万千佰拾元角分";      ...

  5. Java货币金额转换为大写形式

    package com.test; import java.math.BigDecimal; /** * * * 数字转换为汉语中人民币的大写<br> * */ public class ...

  6. odoo中Python实现小写金额转换为大写金额

    自动将小写的金额数值转换为大写,方便记录 class project_parm(models.Model): def IIf(self, b, s1, s2): if b: return s1 els ...

  7. C#实现阿拉伯数字(小写金额)到大写中文(大写金额)的转换

    /// <summary>    /// 本类实现阿拉伯数字到大写中文的转换    /// 该类没有对非法数字进行判别,请事先自己判断数字是否合法    /// </summary& ...

  8. js将人民币金额转换为大写

    function upDigit(n) { var fraction = ['角', '分']; var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒' ...

  9. js 小写金额转大写

    function smalltoBIG(n) { var fraction = ['角', '分']; var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', ...

随机推荐

  1. 洛谷P1018乘积最大——区间DP

    题目:https://www.luogu.org/problemnew/show/P1018 区间DP+高精,注意初始化和转移的细节. 代码如下: #include<iostream> # ...

  2. 实际用户ID和有效用户ID (三) *****

    我们知道权限有r,w,x.其实除了这三个,还有特殊权限.比如: [root@localhost ~]# ls -l /usr/bin/passwd -rwsr-xr-x 1 root root 229 ...

  3. Poco 编译mysql

    POCO mysql需要自己添加connecter的header和lib MySQL Client: For the MySQL connector, the MySQL client librari ...

  4. python3 + selenium + eclipse 中报:Unable to find a matching set of capabilities

    在环境python3 + selenium + eclipse 运行报错::Unable to find a matching set of capabilities 解决办法:Update Fire ...

  5. ie不支持的event.stopPropagation的解决方式

    if (event.stopPropagation) { // 针对 Mozilla 和 Opera event.stopPropagation(); } else if (window.event) ...

  6. [poj3450]Corporate Identity(后缀数组)

    题意:多个字符串的最长公共子串. 解题关键:字符串的任何一个子串都是这个字符串的某个后缀的前缀.求A和B的最长公共子串等价于求A的后缀和B的后缀的最长公共前缀的最大值. 后缀数组的经典例题,连接在一起 ...

  7. PCL推荐的命名规范(2)

    博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=210 函数/成员函数命名 函数和类的成员函数的命名应该采用camelCase ...

  8. CodeForces - 633D Fibonacci-ish 大数标记map+pair的使用

    Fibonacci-ish Yash has recently learnt about the Fibonacci sequence and is very excited about it. He ...

  9. 通俗易懂,什么是.NET Core以及.NET Core能做什么

    作者:依乐祝 原文地址:https://www.cnblogs.com/yilezhu/p/10880884.html 我们都知道.NET Core是一个可以用来构建现代.可伸缩和高性能的跨平台软件应 ...

  10. [Xcode 实际操作]五、使用表格-(9)删除UITableView单元格(手势左滑调出删除按钮)

    目录:[Swift]Xcode实际操作 本文将演示如何删除某一行单元格.手势左滑调出删除按钮. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIK ...