When using mysql, I found that if I store a floating point number, such as 4.5, it will become a number like “4.499999999987”
Now, using mongoDB, I find that 4.5 is still 4.5 when it is stored, so can I believe that this situation must exist? Or does it mean that there is no guarantee that the number I put in is the same as the number I read out
Mongodb uses 64-bit double in bson, because IEEE 754-2008 standard is adopted, all practical results will be better than floating point number calculation results of general programs, but because precision is still limited, all still don’t believe this floating point number is credible.
However, what you can be guaranteed is that the number you put in is still the same, but you should pay attention to the fact that when you put it in, it may have deviated from the value you originally wanted.