You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When specifying a field to be cast as decimal, it is still internally converted to float by the call to number_format. This loses precision.
Steps To Reproduce:
<?php
require('vendor/autoload.php');
use Illuminate\Database\Eloquent\Model;
final class Member extends Model {
public $timestamps = false;
protected $casts = [
'amount' => 'decimal:20',
];
}
$member = new Member();
$member->amount = '0.1';
var_dump($member->amount);
Outputs:
string(22) "0.10000000000000000555"
Expected:
string(22) "0.10000000000000000000"
The text was updated successfully, but these errors were encountered:
Description:
When specifying a field to be cast as decimal, it is still internally converted to float by the call to
number_format
. This loses precision.Steps To Reproduce:
Outputs:
Expected:
The text was updated successfully, but these errors were encountered: