Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]fastjson2 2.0.53出现json转换时在使用了UseBigDecimalForDoubles后,没有将double转换成ddouble #3324

Open
AlexFEIII opened this issue Feb 5, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@AlexFEIII
Copy link

问题描述

fastjson2 2.0.53出现json转换时在使用了UseBigDecimalForDoubles后,没有将double转换成ddouble

问题仅出现在json对象为list时

@AlexFEIII AlexFEIII added the bug Something isn't working label Feb 5, 2025
@AlexFEIII
Copy link
Author

Image

@wenshao
Copy link
Member

wenshao commented Feb 6, 2025

原来UseBigDecimalForDoubles的实现不符合语义修改了,你要得到double使用Feature.UseDoubleForDecimals

@AlexFEIII
Copy link
Author

那请问现在什么情况下用UseDoubleForDecimals,什么情况下用UseDecimalForDoubles?

@wenshao
Copy link
Member

wenshao commented Feb 7, 2025

那请问现在什么情况下用UseDoubleForDecimals,什么情况下用UseDecimalForDoubles?

要将1.234e10这种也使用BigDecimal时用UseDecimalForDoubles

@AlexFEIII
Copy link
Author

也就是说这个是根据数据精度决定的对吗?double在java的有效精度是16位左右,如果使用UseBigDecimalForDoubles的话,会根据数据本身的精度来决定返回double还是BigDecimal?但是我们还发现了一个问题,使用UseBigDecimalForDoubles,当数据精度不高的时候(23.2123456),结果是BigDecimal,而数据精度到了16位的时候,结果是double,这个好像不符合预期,为什么9位的时候转换结果反而是BigDecimal?

@wenshao
Copy link
Member

wenshao commented Feb 7, 2025

带e的parse的缺省是double,带D后缀是Double,带F后缀是Float,比如:

123.45e10 -- double
123.45D -- double
123.45F -- float

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants