Open hiboudev opened 3 months ago
@hiboudev I can't duplicate that here. The value 2387.04123456
saves correctly and remains here. Are you using a FieldtypeFloat field (what I'm using), or using the InputfieldFloat with some other field type?
@ryancramerdesign I did another test, inserting directly in database and I see the same rounding, and here is the solution: https://stackoverflow.com/a/62515384 If I set the type double to this field, it saves correctly the decimal value. My database was created by ProcessWire, so why do we have a difference? Because I'm using InnoDB? What is the type in your database? This is the configurations PW created:
@ryancramerdesign, I can confirm what @hiboudev is experiencing - the value is truncated. My table/fields uses MyISAM engine and utf8_general_ci Collation. As soon I change the data type to double, the value is shown as it should, not truncated.
@ryancramerdesign In FieldtypeFloat, this 'float NOT NULL' should be a 'double NOT NULL'.
public function getDatabaseSchema(Field $field) {
$schema = parent::getDatabaseSchema($field);
$schema['data'] = 'float NOT NULL';
return $schema;
}
@hiboudev, this issue should be fixed in https://github.com/processwire/processwire/commit/6e93844c19387e137b4900fab8b990a898f963bc (PW 3.0.241). Can you confirm?
Field should not be rounded:
I set a value via code or admin: 2387.04123456 and value recorded in database is: 2387.04