VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > 数据分析 >
  • 把大数据数字口语化(python+js)(2)

 

javascript:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function int2string(num) {
    num = Number(num);
    if (num/10000 < 1){
        ret = num;
    }else{
        if (num/Math.pow(10,8) < 1) {
            if (num%10000 != 0) {
                ret = parseInt(num/10000) +'万' + num % 10000;
            }else{
                ret = parseInt(num/10000) +'万';
            }
        }else{
            n2 = num%Math.pow(10,8);
            if (n2%10000 != 0 & n2/10000 != 0) {
                ret = parseInt(num/Math.pow(10,8)) +'亿' + parseInt(n2/10000) +'万' + (n2%10000);
            }else if(n2%10000 != 0 & n2/10000 == 0){
                ret = parseInt(num/Math.pow(10,8)) +'亿' +  parseInt(n2%10000);
            }else if(n2%10000 == 0 & n2/10000 != 0){
                ret = parseInt(num/Math.pow(10,8)) +'亿' +  parseInt(n2/10000) +'万';
            }else if(n2%10000 == 0 & n2/10000 == 0){
                ret = (num/Math.pow(10,8)) +'亿';
            }
        }
    }
    return ret
}


相关教程