top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

MongoDB: $inc generating some wrong value when incremented with negative decimal value

0 votes
481 views

While using $inc to decrement a value by some fractional value,ganerated output differs with expected output.

Steps to reproduce:
1.Insert

db.test.insert({"qty":4.464}

    )

2.check results

db.test.find()

3.increment the value with negative fractional value

db.test.update({},{$inc:{"qty":-0.608}})

4.check the output

db.test.find()

Actual Output: "qty" : 3.8560000000000003
Expected Output: "qty" : 3.856

posted Jun 16, 2017 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
0 votes

I want to implement the encryption and that to only to value in key-value pair in mongodb .Can anyone please provide a workable solution?

+1 vote

Query description: I have a collection name student_db and added a document in a collection with entries (name: "alok, age : 31 and profession: "xyz"). After inserting the document into student_db database, I want to add another (key:value ) pair i.e. salary: 50000.

Can someone help me out to resolve this problem ?

+1 vote

In cluster environment, we have two shards (i.e primary, secondary and arbiter servers in each shard).

We have 64GB RAM and wiredTigerCacheSizeGB is currently 32 (by default). Here I need your advise, these serevers are dedicated to Mongo instances.

Can I change to wiredTigerCacheSizeGB to 50GB (leaving 14GB for OS and other processeses).

0 votes

I want compress the data stored in column more efficient, because mydata is timeseries of stock or future price.
Most of them is similar, so I thought I could compress the price data(float, uint64, int) more efficient than zlib,like what infobright do.

Could any one tell me how to compress the column more efficient or could I get the blocks data type when I write the compress plug.

...