teroristd каза:
Мисля че double е правилното, int закръгля на цяло число.
Може и флоат.
Тук много добре е обяснена разликата между float и double. Double се ползва за по-голяма точност на числото защото се запаметява в двойно повече битове. Флоат има 32 бита (4 байта) с 8 позиции за точност. Дабъл има 64 бита (8 байта) и 16 позиции за точност. Ако числата, които ще въвеждаш не са с примерно повече от 0.12345678 (8) позиции не си ползвай float за спестяване на памет. В противен случай double е твоето решение с 0.123456789 10 11 12 13 14 15 16 (16) позиции на точност.
If you need better accuracy, use Double instead of Float.
http://stackoverflow.com/questions/2160810/mysql-whats-the-difference-between-float-and-double
:?: :arrow:
They both represent floating point numbers. A FLOAT is for single-precision, while a DOUBLE is for double-precision numbers.
MySQL uses four bytes for single-precision values and eight bytes for double-precision values.
There is a big difference from floating point numbers and decimal (numeric) numbers, which you can use with the DECIMAL data type. This is used to store exact numeric data values, unlike floating point numbers, where it is important to preserve exact precision, for example with monetary data.
:arrow:
Perhaps this example could explain.
[sql]CREATE TABLE `test`(`fla` FLOAT,`flb` FLOAT,`dba` DOUBLE(10,2),`dbb` DOUBLE(10,2)); [/sql]
We have a table like this :
[sql]+-------+-------------+
| Field | Type |
+-------+-------------+
| fla | float |
| flb | float |
| dba | double(10,2)|
| dba | double(10,2)|
+-------+-------------+[/sql]
For first difference, we try to insert a record with '1.2' to each field :
[sql]INSERT INTO `test` values (1.2,1.2,1.2,1.2);[/sql]
The table showing like this :
[sql]
SELECT * FROM `test`;
+------+------+------+------+
| fla | flb | dba | dbb |
+------+------+------+------+
| 1.2 | 1.2 | 1.20 | 1.20 |
+------+------+------+------+[/sql]
See the different?
We try to next example:
[sql]
SELECT fla+flb, dba+dbb FROM `test`;[/sql]
Hola! We can find the different like this :
[sql]
+--------------------+---------+
| fla+flb | dba+dbb |
+--------------------+---------+
| 2.4000000953674316 | 2.40 |
+--------------------+---------+[/sql]