how can I store large decimal values in MYSQL?
I have tried to use the decimal(10,9)
but the value ends up being transformed to: 99999999.99
Example: 2110624448.26533720
Expected save value: 2110624448.26533720
Thanks in advance
how can I store large decimal values in MYSQL?
I have tried to use the decimal(10,9)
but the value ends up being transformed to: 99999999.99
Example: 2110624448.26533720
Expected save value: 2110624448.26533720
Thanks in advance
2
Answers
To store the value
2110624448.26533720
without any loss of precision, you need to adjust the precision and scale of yourDECIMAL
column.For example, if you want to store values with up to 8 digits to the left of the
.
and 8 digits to the right of the.
, you can define your column asDECIMAL(16, 8)
:This will allow you to store values like 2110624448.26533720 without any rounding.
In your case, you want to store a value like
2110624448.26533720
which has a precision of 10 and a scale of 8DECIMAL(18, 8)
specifies a total of 18 digits (including both integer and decimal parts) and 8 decimal places.If you’ve already created the table, use the ALTER TABLE statement to modify the column: