Does MongoDB support floating point types?

前端 未结 4 550
余生分开走
余生分开走 2020-12-03 16:31

I am migrating a mysql database to mongodb. But i have read in MongoDb data types and then there is no reference to floating point types like, float, double, decimal.

<
4条回答
  •  一生所求
    2020-12-03 17:28

    Chris already provided information about floating point types, so I will just add information about Decimal data type that was added in Mongo 3.4

    3.4 adds support for the decimal128 format with the new decimal data type. The decimal128 format supports numbers with up to 34 decimal digits (i.e. significant digits) and an exponent range of −6143 to +6144.

    Unlike the double data type, which only stores an approximation of the decimal values, the decimal data type stores the exact value. For example, a decimal NumberDecimal("9.99") has a precise value of 9.99 where as a double 9.99 would have an approximate value of 9.9900000000000002131628...

提交回复
热议问题