2007年8月1日水曜日

データベース/フィールド/浮動小数点数型


REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
| DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
| FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
| DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
| NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]


MySQLでは、REAL, FLOAT, DOUBLE, DOUBLE PRECISIONは、どれも8バイトで
扱える範囲は、-1e+308~+1e+308です。
UNSIGNEDは符号なし、ZEROFILLは頭を0で埋めます。


mysql> create table d (
-> r real,
-> dp double precision,
-> f8 float8,
-> d double );
Query OK, 0 rows affected (0.06 sec)

mysql> insert into d(r) value(-1e+308);
Query OK, 1 row affected (0.05 sec)

mysql> insert into d(r) value(+1e+308);
Query OK, 1 row affected (0.03 sec)

mysql> insert into d(dp) value(-1e+308);
Query OK, 1 row affected (0.02 sec)

mysql> insert into d(dp) value(+1e+308);
Query OK, 1 row affected (0.03 sec)

mysql> insert into d(f8) value(-1e+308);
Query OK, 1 row affected (0.02 sec)

mysql> insert into d(f8) value(+1e+308);
Query OK, 1 row affected (0.02 sec)

mysql> insert into d(d) value(-1e+308);
Query OK, 1 row affected (0.02 sec)

mysql> insert into d(d) value(+1e+308);
Query OK, 1 row affected (0.02 sec)

0 件のコメント: