为什么 Bigdecimal(double d) 结构仍然存在? [英] Why is the Bigdecimal(double d) construction still around?

查看:27
本文介绍了为什么 Bigdecimal(double d) 结构仍然存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经注意到这个构造函数的巨大痛苦(即使在 Stack Overflow 上也是如此).即使文档明确指出,人们也会使用它:

I've noticed substantial pain over this constructor (even here on Stack Overflow). People use it even though the documentation clearly states:

这个构造函数的结果可能有些不可预测http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html#BigDecimal(double)

我什至看到 JSR-13已批准,并附上建议:

I've even seen a JSR-13 being APPROVED with a recommendation stating:

可能被弃用的现有规范:我们建议弃用 BigDecimal(double) 构造函数,它目前给出的结果与 Double.toString() 方法不同.

尽管如此,构造函数尚未被弃用.

Despite all this, the constructor has not yet been deprecated.

我很想听听对此的任何看法.

I'd love to hear any views on this.

推荐答案

弃用已弃用.部分 API 仅在特殊情况下标记为已弃用.

Deprecation is deprecated. Parts of APIs are only marked deprecated in exceptional cases.

因此,在构建过程中运行 FindBugs.FindBugs 有一个检测器插件 API,也是开源的(LGPL、IIRC).

So, run FindBugs as part of your build process. FindBugs has a detector PlugIn API and is also open source (LGPL, IIRC).

这篇关于为什么 Bigdecimal(double d) 结构仍然存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆