@@ -46,14 +46,20 @@ function nft(Number, Decimals = 0) {
46
46
} else {
47
47
WholeLen = Number . length ;
48
48
}
49
- let ThouPos = GroupOffset ;
50
- for ( let Unit = 0 , Pos = WholeLen - 1 ; Pos > - 1 ; Pos -- , Unit ++ ) {
49
+ for ( let OddEven = 'o' , Unit = 0 , Pos = WholeLen - 1 , ThouPos = GroupOffset ; Pos > - 1 ; Pos -- , Unit ++ , OddEven = OddEven === 'o' ? 'e' : 'o' ) {
51
50
if ( ThouPos >= GroupSize ) {
52
51
ThouPos = 1 ;
53
52
Formatted = GroupSeparator + Formatted ;
54
53
} else {
55
54
ThouPos ++ ;
56
55
}
56
+ if ( Unit === 0 ) {
57
+ var Myriads = false ;
58
+ var Hundreds = false ;
59
+ } else {
60
+ var Myriads = ( Unit % % 4 ) === 0 ;
61
+ var Hundreds = Myriads === false && ( Unit % % 2 ) === 0 ;
62
+ }
57
63
var Key = Number . substring ( Pos , Pos + 1 ) ;
58
64
var Double = ( Pos > 0 ) ? Number . substring ( Pos - 1 , Pos ) + Key : '' ;
59
65
let Power = '' ;
@@ -65,9 +71,17 @@ function nft(Number, Decimals = 0) {
65
71
} else if ( typeof ConversionSet [ '+' + Key ] != 'undefined' ) {
66
72
Digit = ConversionSet [ '+' + Key ] ;
67
73
} else {
68
- Digit = ( typeof ConversionSet [ Key ] != 'undefined' ) ? ConversionSet [ Key ] : Key ;
69
- if ( typeof ConversionSet [ '^' + Unit + '*' + Key ] != 'undefined' ) {
70
- Power = ConversionSet [ '^' + Unit + '*' + Key ] ;
74
+ Digit = ( typeof ConversionSet [ OddEven + Key ] != 'undefined' ) ? ConversionSet [ OddEven + Key ] : ( typeof ConversionSet [ Key ] != 'undefined' ) ? ConversionSet [ Key ] : Key ;
75
+ if ( Myriads === true && ( typeof ConversionSet [ 'Myriads' ] != 'undefined' ) ) {
76
+ Power = ConversionSet [ 'Myriads' ] ;
77
+ if ( typeof ConversionSet [ 'Myriads+' + Key ] != 'undefined' ) {
78
+ Digit = ConversionSet [ 'Myriads+' + Key ] ;
79
+ }
80
+ } else if ( Hundreds === true && ( typeof ConversionSet [ 'Hundreds' ] != 'undefined' ) ) {
81
+ Power = ConversionSet [ 'Hundreds' ] ;
82
+ if ( typeof ConversionSet [ 'Hundreds+' + Key ] != 'undefined' ) {
83
+ Digit = ConversionSet [ 'Hundreds+' + Key ] ;
84
+ }
71
85
} else if ( typeof ConversionSet [ '^' + Unit ] != 'undefined' ) {
72
86
Power = ConversionSet [ '^' + Unit ] ;
73
87
}
@@ -90,9 +104,7 @@ function nft(Number, Decimals = 0) {
90
104
} else {
91
105
Digit = ( typeof ConversionSet [ Key ] != 'undefined' ) ? ConversionSet [ Key ] : Key ;
92
106
}
93
- if ( typeof ConversionSet [ '^-' + Pos + '*' + Key ] != 'undefined' ) {
94
- Power = ConversionSet [ '^-' + Pos + '*' + Key ] ;
95
- } else if ( typeof ConversionSet [ '^-' + Pos ] != 'undefined' ) {
107
+ if ( typeof ConversionSet [ '^-' + Pos ] != 'undefined' ) {
96
108
Power = ConversionSet [ '^-' + Pos ] ;
97
109
}
98
110
}
0 commit comments