@@ -378,10 +378,53 @@ if (!NumberLong.prototype) {
378378 NumberLong . prototype = { } ;
379379}
380380
381+ NumberLong . prototype . nativeToString = NumberLong . prototype . toString ;
382+ NumberLong . prototype . toString = function ( ) {
383+ return `NumberLong(${ this . nativeToString ( ) } )` ;
384+ } ;
385+
381386NumberLong . prototype . tojson = function ( ) {
382387 return this . toString ( ) ;
383388} ;
384389
390+ Object . defineProperty ( NumberLong . prototype , 'floatApprox' , {
391+ enumerable : false ,
392+ configurable : true ,
393+ get : function ( ) {
394+ return Number ( this . nativeToString ( ) ) ;
395+ }
396+ } ) ;
397+
398+ Object . defineProperty ( NumberLong . prototype , 'top' , {
399+ enumerable : false ,
400+ configurable : true ,
401+ get : function ( ) {
402+ const str = this . nativeToString ( ) ;
403+ const bigIntValue = BigInt ( str ) ;
404+ const unsigned64 = bigIntValue < 0n
405+ ? bigIntValue + ( 1n << 64n )
406+ : bigIntValue ;
407+ return Number ( ( unsigned64 >> 32n ) & 0xFFFFFFFFn ) ;
408+ }
409+ } ) ;
410+
411+ Object . defineProperty ( NumberLong . prototype , 'bottom' , {
412+ enumerable : false ,
413+ configurable : true ,
414+ get : function ( ) {
415+ const str = this . nativeToString ( ) ;
416+ const bigIntValue = BigInt ( str ) ;
417+ const unsigned64 = bigIntValue < 0n
418+ ? bigIntValue + ( 1n << 64n )
419+ : bigIntValue ;
420+ return Number ( unsigned64 & 0xFFFFFFFFn ) ;
421+ }
422+ } ) ;
423+
424+ NumberLong . prototype . exactValueString = function ( ) {
425+ return this . nativeToString ( ) ;
426+ } ;
427+
385428// NumberInt
386429if ( ! NumberInt . prototype ) {
387430 NumberInt . prototype = { } ;
0 commit comments