LoginSignup
4
5

More than 5 years have passed since last update.

mysqlのfloatは使わないほうが幸せになれる

Last updated at Posted at 2016-03-23

float使って驚いたのでメモ

floatのカラムに
387463300を入力 → 結果: 387463000
387463500を入力 → 結果: 387463000
387463600を入力 → 結果: 387464000

私はこれでポルナレフ状態になりましたwww

どうやら6桁までしか保存できないらしく、
6桁を超えると整数でも容赦なく切り捨てられるか
切り上げられてしまうみたい。

warningも出ないし、大きい数字を扱っている場合は
floatは使わないほうが無難

decimalとか使ったほうがいいんじゃないかな(震え声)


追記
redshiftのfloatはどうやらものが違うらしく、普通に保存される

4
5
4

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
4
5