I have a problem inserting a value into a field in the table, this field is as float (15,6).
I circled an insert here
INSERT INTO valores (valor) VALUES ('1160.480000');
Why does he enter the value as 1160.479980?
I have a problem inserting a value into a field in the table, this field is as float (15,6).
I circled an insert here
INSERT INTO valores (valor) VALUES ('1160.480000');
Why does he enter the value as 1160.479980?
Formalizing the answer:
The error occurs because float
does not store exact details - but rather (monetary values), we should use decimal
. ...
The decimal in MySQL has the capacity to store a maximum of 65 digits, and of these, 30 digits can be used for the decimal.
This response further details the
Another post on the subject .
ALTER TABLE valores MODIFY valor decimal(15,6);
INSERT INTO valores (valor) VALUES (1160.480000);