yapi long型数字值被转换精度

nr7wwzry  于 2021-12-03  发布在  Java
关注(0)|答案(4)|浏览(440)

版本号

~ 1.9.2

什么问题

~long型数字值被转换精度

如何复现此问题

什么浏览器

~ chrome

什么系统(Linux, Windows, macOS)

linux

qvtsj1bj

qvtsj1bj1#

同碰到这个问题,从背景页看插件接收到的响应是{"id": 249655320052916224},但是前端展示出来的是{"id": 249655320052916220},末尾数字被抹成0了
1.9.2版本,macOS,chrome浏览器

cnjp1d6j

cnjp1d6j2#

@L-sing 请参考这里

https://www.w3schools.com/js/js_numbers.asp

JavaScript Numbers are Always 64-bit Floating Point

Unlike many other programming languages, JavaScript does not define different types of numbers, like integers, short, long, floating-point etc.
JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard.
This format stores numbers in 64 bits, where the number (the fraction) is stored in bits 0 to 51, the exponent in bits 52 to 62, and the sign in bit 63.

Integers (numbers without a period or exponent notation) are accurate up to 15 digits.

对于15位以上的长整数,需要转换成字符串来做传输。

wnavrhmk

wnavrhmk3#

那只有协调开发转换了

bwitn5fc

bwitn5fc4#

我也遇到了同样的问题。json-bigint,就不能用吗?我想自己改个,可惜无从下手,不了解原理。

相关问题