Reputation: 8618
This is my migrations
$table->float('odd', 10, 0)->nullable();
I save odd value in db as 4.45
but it returned as 4.45000000000000017763568394002504646778106689453125
I look this post Laravel Eloquent double value stored in database returned rounded
but that is not solve my problem. Also problems only occur in server
How can solve it?
Upvotes: 2
Views: 5249
Reputation: 73
I know I am a little late, but maybe this can help someone.
PHP7.1 json_encode() Float Issue
TLDR
The problem is in serialize_precision in php.ini https://www.php.net/manual/en/ini.core.php
Mine was set to 100 and it caused me the same problems. Setting to -1 resolved it.
Upvotes: 1