Skip to content

Commit

Permalink
If the float is infinite, print the INF constant
Browse files Browse the repository at this point in the history
  • Loading branch information
mahills committed May 4, 2014
1 parent fb13b72 commit ee78214
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Rascal/RascalPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,12 @@ public function pprintParam(\PhpParser\Node\Param $node)

public function pprintDNumberScalar(\PhpParser\Node\Scalar\DNumber $node)
{
$fragment = "float(" . sprintf('%f', $node->value) . ")";
$fragment = "scalar(" . $fragment . ")";
if (is_infinite($node->value)) {
$fragment = "fetchConst(name(\"INF\"))";
} else {
$fragment = "float(" . sprintf('%f', $node->value) . ")";
$fragment = "scalar(" . $fragment . ")";
}
$fragment .= $this->annotateASTNode($node);

return $fragment;
Expand Down

0 comments on commit ee78214

Please sign in to comment.