I will partially answer your question (because I know little about C #).
So, what do you lose if you save the decimal numbers as strings.
- your numbers will weigh more on average (each double number costs 8 bytes for storage , which means that each line with more than 8 characters will be more weight). Because of this, your indexes (if they are built on this field, will grow)
- you cannot use operators that take numbers as arguments $ inc , $ bit , $ mod , $ min , $ max and in version 2.6 of $ mul . (Maybe I forgot something)
- you cannot compare numbers (maybe "1.65" and "1.23" is comparable to a string, but definitely not numbers with e and minuses somewhere in the middle). Due to these operations, which are based on comparison, for example $ sort , and all these $ gte, $ gt, $ lte, $ lt will not work correctly.
What do you lose in accuracy if you save the decimal as double :
- based on this, Decimal in C # has 28-29 significant digits, while looking at my first link and checking the spec for double precision , you see that it has 15-17 significant digits. This is basically what you lose.
- The following really important thing that people sometimes forget when working with double floats:
.
db.c.insert({_id : 1, b : 3.44}) db.c.update({_id : 1},{$inc : {b : 1}}) db.c.find({b: 4.44}) // WTf, where is my document? There is nothing there
Regarding the 2nd subquery:
Is there a way to set default serialization of decimal places to double (AllowTruncation) without having to assign an attribute to each property?
I really do not understand this, so I hope someone can answer it.
Salvador dali
source share