[CSHARP-1594] Add support for Decimal128 BSON type Created: 07/Mar/16 Updated: 27/May/22 Resolved: 01/Sep/16 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | BSON |
| Affects Version/s: | None |
| Fix Version/s: | 2.4 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Rathi Gnanasekaran | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Epic Link: | MongoDB 3.4 | ||||||||||||
| Server Compat: | 3.3 | ||||||||||||
| Description |
|
Add driver support for a new BSON type for decimal numbers, which will be added to MongoDB in version 3.4. This type will use the decimal128 format as defined by the IEEE 754 standard and support up to 34 decimal digits and a range from -9.999999999999999999999999999999999×10^6144 to +9.999999999999999999999999999999999×10^6144. It also supports positive and negative zero, positive and negative infinity, and two forms of NaN (regular and signaled). Decimal values will be treated like any other numeric type, and compare and sort correctly with other types based on actual numeric value. Operations on decimals are implemented in accordance with the standard, so a value of 0.10 will retain its trailing zeros while comparing equal to 0.1, 0.10000 etc. |
| Comments |
| Comment by Shawn Shaddock [ 03/Dec/16 ] |
|
As George stated, I am also having the same experience. By default System.Decimal is still serializing to strings. I tried to force them to serialize to Decimal128 using [BsonRepresentation(BsonType.Decimal128)] but then I get an error when performing an InsertOneAsync: I am using: |
| Comment by George Jreige [ 25/Nov/16 ] |
|
Hi All, I am trying out the c# 2.4-beta2 driver and it seems it is still treating decimals as strings and sending a string value in the query to mongo. I am using "MongoDB.Driver": "2.4.0-beta1" in my project.json and I have mongo server 3.4 running. My filter def is: filter = filter & builder.Gte(x => x.Price, info.PriceFrom) info.PriceFrom and info.PriceTo are decimals and the documents in mongo are decimals not strings. The output of the query to mongo is: find({"Price" : { "$gte" : "0", "$lte" : "100000000" }}). Query works fine when I modify the query and run it in the Mongo shell as such: find({"Price" : { "$gte" : 0, "$lte" : 100000000 }}) Am I missing something here? It very well could be me... Regards, |
| Comment by Githook User [ 29/Sep/16 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 24/Sep/16 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 21/Sep/16 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 16/Sep/16 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 01/Sep/16 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |