Hi,
- My table has few fields with an amount column of type decimal.
- This column will have either a deposited amount (a positive value) or a withdraw amount (a negative value).
- I store the positive value as just 120 and the negative value as -50.
- I sum the column and got the result as expected.
- Mysql version is: 5.1.33-community.
When i checked mysql documentation about decimal i confused with their description.
Before MySQL 5.0.3, if you inserted +0003.1 into a DECIMAL(5,1) column, it was stored as +0003.1. As of MySQL 5.0.3, it is stored as 3.1. For negative numbers, a literal - character is no longer stored. Applications that rely on the older behavior must be modified to account for this change. http://dev.mysql.com/doc/refman/5.0/en/precision-math-decimal-changes.html
When i listed the rows in phpmyadmin i could see the negative sign and when i calculated the result was as expected. but the documentation said no sign will appear.
Is it good to store negative number in decimal(haven't i studied in school? confused)?... or do we have to use float.
I learn't that float would complicate calculations and was advised to stick with decimal for certain conditions.
I would like to have suggestions for this.