/** 数字金额大写转换(可以处理整数,小数,负数) */
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. BZOJ3196:二逼平衡树

    浅谈树状数组与线段树:https://www.cnblogs.com/AKMer/p/9946944.html 浅谈\(Splay\):https://www.cnblogs.com/AKMer/p/ ...

  2. bzoj 4319 Suffix reconstruction —— 贪心构造

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4319 思维还是不行...这样的构造都没思路... 首先,我们可以按 rank 的顺序从小到大 ...

  3. Apache日志解读

    想要知道什么人在什么时候浏览了网站的哪些内容吗?查看Apache的访问日志就可以知道.访问日志是Apache的标准日志,本文详细解释了访问日志的内容以及相关选项的配置. 一.访问日志的格式  Apac ...

  4. Windows下caffe安装详解(仅CPU)

    本文大多转载自 http://blog.csdn.net/guoyk1990/article/details/52909864,加入部分自己实战心得. 1.环境:windows 7\VS2013 2. ...

  5. PCL中异常处理机制

    博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=287 本节我们主要讨论PCL在编写和应用过程中如何利用PCL的异常机制,提高 ...

  6. 《SpringBoot揭秘 快速构建微服务体系》读后感(二)

    最简单的springBoot应用 package com.louis.test; import org.springframework.boot.SpringApplication; import o ...

  7. 51Nod - 1154 回文串划分(最少回文串dp)

    回文串划分 有一个字符串S,求S最少可以被划分为多少个回文串. 例如:abbaabaa,有多种划分方式.   a|bb|aabaa - 3 个回文串 a|bb|a|aba|a - 5 个回文串 a|b ...

  8. HDU - 3499 Flight 双向SPFA+枚举中间边

    Flight Recently, Shua Shua had a big quarrel with his GF. He is so upset that he decides to take a t ...

  9. app.config 配置的一种用法

    app.config文件 <?xml version="1.0" encoding="utf-8" ?> <configuration> ...

  10. Mac 下nginx 环境的配置

    这个是在度娘那里学来的. 因为是使用brew所以先安装: 安装命令如下:curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo ...