@@ -4,7 +4,7 @@ function Decimal(num) {
4
4
}
5
5
6
6
if ( num instanceof Decimal ) {
7
- return num ;
7
+ return num ;
8
8
}
9
9
10
10
this . internal = String ( num ) ;
@@ -21,19 +21,19 @@ Decimal.prototype._get_repr = function() {
21
21
22
22
23
23
if ( ! post ) {
24
- var trailing_zeros = pre . match ( / 0 + $ / ) ;
25
-
26
- if ( trailing_zeros ) {
27
- var l = trailing_zeros [ 0 ] . length ;
28
- value = pre . substr ( 0 , pre . length - l ) ;
29
- exp = l ;
30
- } else {
31
- value = pre ;
32
- exp = 0 ;
33
- }
24
+ var trailing_zeros = pre . match ( / 0 + $ / ) ;
25
+
26
+ if ( trailing_zeros ) {
27
+ var l = trailing_zeros [ 0 ] . length ;
28
+ value = pre . substr ( 0 , pre . length - l ) ;
29
+ exp = l ;
30
+ } else {
31
+ value = pre ;
32
+ exp = 0 ;
33
+ }
34
34
} else {
35
- value = parseInt ( this . internal . split ( '.' ) . join ( '' ) , 10 ) ;
36
- exp = post . length * - 1 ;
35
+ value = parseInt ( this . internal . split ( '.' ) . join ( '' ) , 10 ) ;
36
+ exp = post . length * - 1 ;
37
37
}
38
38
39
39
return { 'value' :value , 'exp' :exp } ;
@@ -46,15 +46,15 @@ Decimal.prototype.add = function(target) {
46
46
var ops = [ this , target ] ;
47
47
ops . sort ( function ( x , y ) { return x . repr . exp - y . repr . exp } ) ;
48
48
49
- var tiniest = ops [ 0 ] . repr . exp ;
49
+ var smallest = ops [ 0 ] . repr . exp ;
50
50
var biggest = ops [ 1 ] . repr . exp ;
51
51
52
- var fst = Decimal . _format ( ops [ 1 ] . repr . value , biggest - tiniest ) * 1 ;
52
+ var fst = Decimal . _format ( ops [ 1 ] . repr . value , biggest - smallest ) * 1 ;
53
53
var snd = ops [ 0 ] . repr . value * 1 ;
54
54
55
55
var calc = String ( fst + snd ) ;
56
56
57
- return Decimal . _format ( calc , tiniest ) ;
57
+ return Decimal . _format ( calc , smallest ) ;
58
58
}
59
59
60
60
Decimal . prototype . sub = function ( target ) {
@@ -84,8 +84,8 @@ Decimal._neg_exp = function(str, position) {
84
84
var sep = '.'
85
85
86
86
if ( offset >= 0 ) {
87
- str = Decimal . __zero ( offset ) + str ;
88
- sep = '0.' ;
87
+ str = Decimal . __zero ( offset ) + str ;
88
+ sep = '0.' ;
89
89
}
90
90
91
91
var length = str . length ;
@@ -114,7 +114,7 @@ Decimal.__zero = function(exp) {
114
114
for ( var i = 0 ; i < methods . length ; i ++ ) {
115
115
( function ( method ) {
116
116
Decimal [ method ] = function ( a , b ) {
117
- return Decimal ( a ) [ method ] ( b ) ;
117
+ return Decimal ( a ) [ method ] ( b ) ;
118
118
}
119
119
} ) ( methods [ i ] ) ;
120
120
}
0 commit comments