I want to save currency values in a mysql db – curreny_data table. so I created a sale_price field which is a double unsigned. When I am going to save minus values db generate a error and save default value zero(0). But when I am going to save minus zero(-0) it saves successfully. I am confused. Please I need some help.
Share
Isn’t that obvious? an unsigned double (assuming such a type exists) takes only unsigned, i.e. non negative double values. MySQL is smart enough to know that -0 is the same as 0, so it allows you to put -0 in the field. OTOH, negative numbers (by definition of the field) are not allowed, so you get an error.
Negative values will work if you redefine the field as a
decimaltype