NumberLong conversion fails for negative numbers
                
                Solved
            Calculations with documents holding NumberLong values produce wrong results, when negative numbers are involved.
When running the following code in the query editor, -2 is printed, although -1 would be correct:
var val = NumberLong("-1");print(val); // prints -2Also, when you do calculations, it fails: var v1 = NumberLong("-1");
var v2 = NumberLong("-1");
var result = v1 + v2;
print(result); // prints -4This causes some reports we tried to build to be wrong. Interestingly, it works correctly with NumberInt("-1")
Using NoSQLBooster Version 4.7.3 on MacOS 10.13.6
                                                                    
            
            
            The same problem        
                                 
            
We have worked out a new build(4.7.4) to resolve the NumberLong.prototype.valueOf issue, please download and give it a try.
https://nosqlbooster.com/downloads
We have worked out a new build(4.7.4) to resolve the NumberLong.prototype.valueOf issue, please download and give it a try.
https://nosqlbooster.com/downloads
NumberLong.prototype.valueOf has a bug, we will fix it as soon as possible. This bug affects the calculated value but not the stored value.
As a workaround solution, you can use NumberLong.toNumber() method.
var v1 = NumberLong("-1").toNumber(); var v2 = NumberLong("-1").toNumber(); var result = v1 + v2; print(result); // prints -2NumberLong.prototype.valueOf has a bug, we will fix it as soon as possible. This bug affects the calculated value but not the stored value.
As a workaround solution, you can use NumberLong.toNumber() method.
var v1 = NumberLong("-1").toNumber(); var v2 = NumberLong("-1").toNumber(); var result = v1 + v2; print(result); // prints -2We have worked out a new build(4.7.4) to resolve the NumberLong.prototype.valueOf issue, please download and give it a try.
https://nosqlbooster.com/downloads
We have worked out a new build(4.7.4) to resolve the NumberLong.prototype.valueOf issue, please download and give it a try.
https://nosqlbooster.com/downloads
I can confirm it works correctly now.
Wow, that was a fast fix! Thanks a ton! Good work!
I can confirm it works correctly now.
Wow, that was a fast fix! Thanks a ton! Good work!
Replies have been locked on this page!