@@ -89,7 +89,7 @@ function divideu128(value) {
89
89
_rem = _rem . shiftLeft ( 32 ) ;
90
90
// Add the divided to _rem
91
91
_rem = _rem . add ( new Long ( value . parts [ i ] , 0 ) ) ;
92
- value . parts [ i ] = _rem . div ( DIVISOR ) . low_ ;
92
+ value . parts [ i ] = _rem . div ( DIVISOR ) . low ;
93
93
_rem = _rem . modulo ( DIVISOR ) ;
94
94
}
95
95
@@ -126,15 +126,15 @@ function multiply64x2(left, right) {
126
126
127
127
function lessThan ( left , right ) {
128
128
// Make values unsigned
129
- const uhleft = left . high_ >>> 0 ;
130
- const uhright = right . high_ >>> 0 ;
129
+ const uhleft = left . high >>> 0 ;
130
+ const uhright = right . high >>> 0 ;
131
131
132
132
// Compare high bits first
133
133
if ( uhleft < uhright ) {
134
134
return true ;
135
135
} else if ( uhleft === uhright ) {
136
- const ulleft = left . low_ >>> 0 ;
137
- const ulright = right . low_ >>> 0 ;
136
+ const ulleft = left . low >>> 0 ;
137
+ const ulright = right . low >>> 0 ;
138
138
if ( ulleft < ulright ) return true ;
139
139
}
140
140
@@ -153,7 +153,6 @@ function invalidErr(string, message) {
153
153
* @return {Double }
154
154
*/
155
155
function Decimal128 ( bytes ) {
156
- this . _bsontype = 'Decimal128' ;
157
156
this . bytes = bytes ;
158
157
}
159
158
@@ -499,7 +498,7 @@ Decimal128.fromString = function(string) {
499
498
significand . high
500
499
. shiftRightUnsigned ( 49 )
501
500
. and ( Long . fromNumber ( 1 ) )
502
- . equals ( Long . fromNumber )
501
+ . equals ( Long . fromNumber ( 1 ) )
503
502
) {
504
503
// Encode '11' into bits 1 to 3
505
504
dec . high = dec . high . or ( Long . fromNumber ( 0x3 ) . shiftLeft ( 61 ) ) ;
@@ -525,27 +524,27 @@ Decimal128.fromString = function(string) {
525
524
526
525
// Encode the low 64 bits of the decimal
527
526
// Encode low bits
528
- buffer [ index ++ ] = dec . low . low_ & 0xff ;
529
- buffer [ index ++ ] = ( dec . low . low_ >> 8 ) & 0xff ;
530
- buffer [ index ++ ] = ( dec . low . low_ >> 16 ) & 0xff ;
531
- buffer [ index ++ ] = ( dec . low . low_ >> 24 ) & 0xff ;
527
+ buffer [ index ++ ] = dec . low . low & 0xff ;
528
+ buffer [ index ++ ] = ( dec . low . low >> 8 ) & 0xff ;
529
+ buffer [ index ++ ] = ( dec . low . low >> 16 ) & 0xff ;
530
+ buffer [ index ++ ] = ( dec . low . low >> 24 ) & 0xff ;
532
531
// Encode high bits
533
- buffer [ index ++ ] = dec . low . high_ & 0xff ;
534
- buffer [ index ++ ] = ( dec . low . high_ >> 8 ) & 0xff ;
535
- buffer [ index ++ ] = ( dec . low . high_ >> 16 ) & 0xff ;
536
- buffer [ index ++ ] = ( dec . low . high_ >> 24 ) & 0xff ;
532
+ buffer [ index ++ ] = dec . low . high & 0xff ;
533
+ buffer [ index ++ ] = ( dec . low . high >> 8 ) & 0xff ;
534
+ buffer [ index ++ ] = ( dec . low . high >> 16 ) & 0xff ;
535
+ buffer [ index ++ ] = ( dec . low . high >> 24 ) & 0xff ;
537
536
538
537
// Encode the high 64 bits of the decimal
539
538
// Encode low bits
540
- buffer [ index ++ ] = dec . high . low_ & 0xff ;
541
- buffer [ index ++ ] = ( dec . high . low_ >> 8 ) & 0xff ;
542
- buffer [ index ++ ] = ( dec . high . low_ >> 16 ) & 0xff ;
543
- buffer [ index ++ ] = ( dec . high . low_ >> 24 ) & 0xff ;
539
+ buffer [ index ++ ] = dec . high . low & 0xff ;
540
+ buffer [ index ++ ] = ( dec . high . low >> 8 ) & 0xff ;
541
+ buffer [ index ++ ] = ( dec . high . low >> 16 ) & 0xff ;
542
+ buffer [ index ++ ] = ( dec . high . low >> 24 ) & 0xff ;
544
543
// Encode high bits
545
- buffer [ index ++ ] = dec . high . high_ & 0xff ;
546
- buffer [ index ++ ] = ( dec . high . high_ >> 8 ) & 0xff ;
547
- buffer [ index ++ ] = ( dec . high . high_ >> 16 ) & 0xff ;
548
- buffer [ index ++ ] = ( dec . high . high_ >> 24 ) & 0xff ;
544
+ buffer [ index ++ ] = dec . high . high & 0xff ;
545
+ buffer [ index ++ ] = ( dec . high . high >> 8 ) & 0xff ;
546
+ buffer [ index ++ ] = ( dec . high . high >> 16 ) & 0xff ;
547
+ buffer [ index ++ ] = ( dec . high . high >> 24 ) & 0xff ;
549
548
550
549
// Return the new Decimal128
551
550
return new Decimal128 ( buffer ) ;
@@ -682,7 +681,7 @@ Decimal128.prototype.toString = function() {
682
681
// Peform the divide
683
682
let result = divideu128 ( significand128 ) ;
684
683
significand128 = result . quotient ;
685
- least_digits = result . rem . low_ ;
684
+ least_digits = result . rem . low ;
686
685
687
686
// We now have the 9 least significant digits (in base 2).
688
687
// Convert and output to string.
@@ -789,4 +788,5 @@ Decimal128.prototype.toJSON = function() {
789
788
return { $numberDecimal : this . toString ( ) } ;
790
789
} ;
791
790
791
+ Object . defineProperty ( Decimal128 . prototype , '_bsontype' , { value : 'Decimal128' } ) ;
792
792
module . exports = Decimal128 ;
0 commit comments