Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

spring mvc msg-converter 整型精度问题 #498

Closed
myshzzx opened this issue Feb 3, 2016 · 4 comments
Closed

spring mvc msg-converter 整型精度问题 #498

myshzzx opened this issue Feb 3, 2016 · 4 comments

Comments

@myshzzx
Copy link
Contributor

myshzzx commented Feb 3, 2016

js 能精确处理的整型数值上限是 2^53-1, 大约16个有效数字, 超出部分无法保存, 比如 1454469996415019862 会变成 1454469996415019800, 浏览器直接从服务端取json数据并转换会得到错误的结果.
FastJsonHttpMessageConverter 能考虑增加将大整型数值转换成字符串的功能吗? 比如加到 BrowserCompatible feature 里.

@wenshao
Copy link
Member

wenshao commented Feb 3, 2016

哇,这么大的数字,用在什么场景?

@myshzzx
Copy link
Contributor Author

myshzzx commented Feb 3, 2016

用在库表主键, 懒得用序列生成主键, 用基于时间的方式生成主键, 冲突的概率很小, 用在管理系统是可以接受的. 结果丢到页面发现出问题了, 服务端返回json数据, 页面渲染后id太大, 值就变了
(System.currentTimeMillis() * 100 + c.incrementAndGet() % 100) * 10_000 + System.nanoTime() % 10_000
5秒7线程, 冲突率 8/10699664

@wenshao
Copy link
Member

wenshao commented Feb 28, 2016

已经解决,请等待1.2.8版本

@wenshao wenshao closed this as completed Feb 28, 2016
@wenshao
Copy link
Member

wenshao commented Feb 28, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants