0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Item 60: Avoid float and double if exact answers are required

Posted at

60.正確な値を求める場合はfloatとdoubleの使用を控えるべし

  • 特に金の計算には使わないほうが良い。floatとdoubleでは0.1を表現できない。代わりにBigDecimal、int、longを用いる。

  • BigDecimalのデメリットは、使いづらく、遅いところ。

  • 9桁以下の計算にはintを、18桁以下ならlongを、19桁以上ならBigDecimalを使うべき。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?