Marklogic 10 中的最大小数精度是多少以及如何在我的 json 文档中使用?

What is maximum decimal precision in Marklogic 10 and How to use in my json document?

我正在尝试插入一个 JSON 文档,其小数点精度超过 10 位,但它自动将四舍五入应用到 9,当我得到该文档时,它只显示 9 位小数精度.

declareUpdate(); 
var uri = '/test.json'; 
var root = { id: 1, value: 56900.123456789012345678901 }; 
xdmp.documentInsert(uri, root);

知道在 MarkLogic 中 insert/get 超过 9 位小数精度吗?

在 JSON 中,数字是双精度的。

https://www.rfc-editor.org/rfc/rfc7159

Since software that implements IEEE 754-2008 binary64 (double precision) numbers [IEEE754] is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision. A JSON number such as 1E400 or 3.141592653589793238462643383279 may indicate potential interoperability problems, since it suggests that the software that created it expects receiving software to have greater capabilities for numeric magnitude and precision than is widely available.

因此,您将获得最多 17 位有效数字。

https://en.wikipedia.org/wiki/Double-precision_floating-point_format

The 53-bit significand precision gives from 15 to 17 significant decimal digits precision (2−53 ≈ 1.11 × 10−16). If a decimal string with at most 15 significant digits is converted to IEEE 754 double-precision representation, and then converted back to a decimal string with the same number of digits, the final result should match the original string. If an IEEE 754 double-precision number is converted to a decimal string with at least 17 significant digits, and then converted back to double-precision representation, the final result must match the original number.[1]

如果在浏览器控制台中执行以下命令,您将得到相同的结果:

56900.123456789012345678901 + 0

它returns

56900.12345678901

如果将小数点右移,则有效位数相同:

5690012345678901.2345678901 + 0

产量:

5690012345678901

您可以将该值存储为字符串,以保持完整的精度,但如果转换为任何受支持的数字类型,它可能会丢失。

你需要那种精度来做什么?