zoukankan      html  css  js  c++  java
  • 数字转中文大写

     1 static str Num2ChnStr(real realNum)
     2 {
     3        real    y;
     4        int     b, a;
     5        str     je, x, hz1, hz2, e, h, f, m;
     6        boolean IsNegative=false;
     7        ;
     8        if (realNum == 0)
     9                return '零圆';
    10        if (realNum < 0)
    11        {
    12               realNum    = abs(realNum);
    13               IsNegative = true;
    14        }
    15 
    16        y   = realNum;
    17        x   = strLtrim(strRtrim(num2str(y, 20, 2, 1, 0)));
    18        b   = strLen(x) - 3;
    19        a   = 1;
    20        e   = substr(x, a, 1);
    21        hz2 = '零壹贰叁肆伍陆柒捌玖';
    22        hz1 = '仟佰拾亿仟佰拾万仟佰拾圆';
    23        je  = '';
    24        while (e != '.')
    25        {
    26               h = subStr(hz2, str2num(e) * 2 + 1, 2);
    27               f = subStr(hz1, 24 - (b - a) * 2 - 1, 2);
    28               if (e != '0' || (e == '0' && (f == '亿' || f == '' || f == '')))
    29                 je = strLtrim(strRtrim(je)) + h + f;
    30               else
    31                 je = strLtrim(strRtrim(je)) + h;
    32               a = a + 1;
    33               e = subStr(x, a, 1);
    34        }
    35        a = a + 1;
    36        e = subStr(x, a, 1);
    37        h = subStr(x, a + 1, 1);
    38        if (e == '0' && h == '0')
    39          je = je + '';
    40        else
    41        {
    42          if (e == '0')
    43              je = je + '' + subStr(hz2, str2num(h) * 2 + 1, 2) + '';
    44          else if (h == '0')
    45              je = je + substr(hz2, str2num(e) * 2 + 1, 2) + '角整';
    46          else
    47              je = je + substr(hz2, str2num(e) * 2 + 1, 2) + '' + subStr(hz2, str2num(h) * 2 + 1, 2) + '';
    48        }
    49        b = strLen(je);
    50        a = 1;
    51        while (a < b)
    52        {
    53          m = substr(je, a, 4);
    54          if (m == '零圆' || m == '零万' || m == '零亿' || m == '零零')
    55          {
    56              je =subStr(je, 1, a - 1) + strLtrim(strRtrim(substr(je, a + 2, 40)));
    57                a = a - 2;
    58                b = b - 2;
    59          }
    60          a = a + 2;
    61        }
    62  
    63        if (subStr(je, 1, 2) == '' && strLen(je) > 2)
    64          je = subStr(je, 3, strLen(je) - 2);
    65        if (IsNegative)
    66          je = '' + je;
    67        return je;
    68 }

    amount in words(大写金额)

    在AX5.0中,在Global中对应转换的方法。如:numeralsToTxt_EN()。

  • 相关阅读:
    .NET性能调优之三:YSlow相关规则的调优工具和方法
    .NET性能调优之二:使用Visual Studio进行代码度量
    OSPF的常见前7类LSA详解
    Packet Tracer 5.3搭建DNS服务器
    中型网络中网络冗余设计的要领
    GNS3模拟器如何保存配置文件
    CCNA相当综合的实验1
    GNS模拟器中支持的模块说明
    典型配置:H3C基于AP限制接入客户端数量
    破解H3C交换机密码的方法
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2663256.html
Copyright © 2011-2022 走看看