1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-30 04:19:30 +01:00

Increase float pretty printing precision

This removes the reliance on the "precision" ini setting.
Furthermore the default of precision=14 is not sufficient.
This commit is contained in:
Nikita Popov 2015-05-01 19:15:33 +02:00
parent 23bf4f0c13
commit 648800f07f
2 changed files with 3 additions and 1 deletions

View File

@ -96,7 +96,7 @@ class Standard extends PrettyPrinterAbstract
} }
public function pScalar_DNumber(Scalar\DNumber $node) { public function pScalar_DNumber(Scalar\DNumber $node) {
$stringValue = (string) $node->value; $stringValue = sprintf('%.16G', $node->value);
// ensure that number is really printed as float // ensure that number is really printed as float
return preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue; return preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue;

View File

@ -37,6 +37,7 @@ FALSE;
1e1000; 1e1000;
1E-100; 1E-100;
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000; 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
378282246310005.0;
// strings (normalized to single quoted) // strings (normalized to single quoted)
'a'; 'a';
@ -112,6 +113,7 @@ FALSE;
INF; INF;
1.0E-100; 1.0E-100;
1.0E+84; 1.0E+84;
378282246310005.0;
// strings (normalized to single quoted) // strings (normalized to single quoted)
'a'; 'a';
'a 'a