Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Javaで Number 型のオブジェクトにモジュラス関数を適用する安全な方法はありますか?
コレクションにフィルターを適用する「Number-generic」な方法を作ろうとしています。
唯一の一般的なアプローチは、抽象Numberクラスで定義されたメソッドのみを操作することです。そのため、「安全」とは、精度を失わないことを意味する場合、そうではありませんNumber。floatValue()およびdoubleValue()、丸めのみ)。
Number
floatValue()
doubleValue()