Skip to content

Commit a713924

Browse files
committed
loop is not needed
1 parent a80000f commit a713924

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/Persistence/Sql/Expression.php

+2-12
Original file line numberDiff line numberDiff line change
@@ -628,19 +628,9 @@ public function execute(object $connection = null): DbalResult
628628
final public static function castFloatToString(float $value): string
629629
{
630630
$precisionBackup = ini_get('precision');
631+
ini_set('precision', '-1');
631632
try {
632-
// loop needed, see https://github.com/php/php-src/issues/8509
633-
// fixed precision of 17 for conversion can render unneeded decimal digits like
634-
// 0.40000000000000002 although 0.4 is enough to represent such float number exactly
635-
for ($i = 1; $i <= 17; ++$i) {
636-
ini_set('precision', (string) $i);
637-
$res = (string) $value;
638-
if ((float) $res === $value) {
639-
return $res;
640-
}
641-
}
642-
643-
return $res;
633+
return (string) $value;
644634
} finally {
645635
ini_set('precision', $precisionBackup);
646636
}

0 commit comments

Comments
 (0)