Friday, 15 June 2012

MySQL operators' precision on double -



MySQL operators' precision on double -

i'm trying store currency value in mysql (innodb) , need write queries aggregate records (sum) , i'm having problem precision of the output!

i've set field's type double , values precise mysql's operators not precise need. worth, php's default operators not precise plenty either there's bc* functions in php can trick.

i wondering if there's way tune precision of mysql operators? including aggregation functions?

for record, storing , retrieving mysql won't impact values means double ideal type fields.

since money needs exact representation don't utilize info types approximate double floating-point. can utilize fixed-point numeric info type like

numeric(15,2) 15 precision (total length of value including decimal places) 2 number of digits after decimal point

see mysql numeric types:

these types used when of import preserve exact precision, illustration monetary data.

mysql precision

No comments:

Post a Comment