LoginSignup
1
1

More than 3 years have passed since last update.

NumberFormatterで少数点有りの値をカンマ区切りにする際は注意してほしい

Posted at

問題

桁数が多い値をDouble型へキャストする際に、DoubleのイニシャライザやNSStringを使用すると四捨五入が発生する場合があるようです。
スクリーンショット 2019-10-13 1.01.47.png

解決策

NSDecimalNumberを使用して、string(from: NSNumber)を使うことで解決します。
スクリーンショット 2019-10-13 1.04.13.png

1
1
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
1
1