dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

浮点型精度变化bug

Open miaoyoumeng opened this issue 12 years ago • 2 comments

dubbo远程调用带HashMap参数时,如果HashMap中的值是float类型,那么在provider方接受到的对应参数值将发生变化。 例如,rpc请求发送参数: HashMap<String, Object> contentMap = new HashMap<String, Object>(); contentMap.put("price", Float.valueOf(21.32f)); 那么在provider方接受到的对应的“price”值为:21.31999969482422。 我们对这个问题的修改方案是在BasicSerializer类的writeObject方法的FLOAT和DOUBLE分别处理。 我的联系邮箱:[email protected]

miaoyoumeng avatar Jun 17 '14 08:06 miaoyoumeng

这个是计算机浮点数表示的问题,21.32f,计算机表示就是21.3199999.....的,建议使用string转换,你可以参照:http://blog.163.com/liucy_18/blog/static/5319290620106239333519/

enson16855 avatar Jun 25 '14 04:06 enson16855

退订

发自网易邮箱大师

在2017年10月16日 16:46,qinliujie[email protected] 写道:

Closed #57.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

RylanStar avatar Oct 16 '17 08:10 RylanStar