Consolidate float-to-C++ literal generation into Utils::genFloatLiteral().
Previously:
- genCValue() stringified floats directly via (string), emitting 'INF', '-INF', 'NAN', or losing the floating-point decimal point for whole numbers like 1.0 -> '1'.
- BinaryOpTrait::genFloatLiteral() used sprintf('%.17g') without handling INF or NAN.
Now all float code generation paths delegate to Utils::genFloatLiteral(), mapping INF/-INF/NAN to std::numeric_limits<double> and ensuring whole numbers retain .0.
master
parent
b493ac79c5
commit
2d81626a84
10 changed files with 135 additions and 34 deletions
@ -0,0 +1,19 @@ |
||||
<?php |
||||
|
||||
class FloatDeclarationContainer |
||||
{ |
||||
public const float POSITIVE_INF = INF; |
||||
public const float NEGATIVE_INF = -INF; |
||||
public const float NOT_A_NUMBER = NAN; |
||||
public const float CONST_E = M_E; |
||||
public const float CONST_ONE_POINT_FIVE = 1.5; |
||||
|
||||
public float $property_e = M_E; |
||||
public float $property_inf = INF; |
||||
public float $property_nan = NAN; |
||||
public float $property_one_point_five = 1.5; |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
} |
||||
@ -0,0 +1,13 @@ |
||||
<?php |
||||
|
||||
function get_special_floats(): array |
||||
{ |
||||
return [ |
||||
1.0, |
||||
0.0, |
||||
INF, |
||||
-INF, |
||||
NAN, |
||||
M_E, |
||||
]; |
||||
} |
||||
Loading…
Reference in new issue