MySQL - Rounding

Posted 1 year ago by fabricecw


Our Laravel application's database runs on a MySQL 5.7.21 server. We store some float values with up to 6 decimal places into a double field with 2 decimal places. MySQL automatically rounds the value to 2 decimals.

Now the rounding function rounds for example 6.025 to 6.02 instead of 6.03. But 5 should be rounded up (mathematically round). MySQL rounds 6.026 correctly to 6.03.

Anyone knows where or how I can fix this? Otherwise we will round the value before storing it to the DB.

Thanks and regards

Please sign in or create an account to participate in this conversation.