Open jesseschalken opened 8 years ago
Updated repro, since devision by zero throws a DivisionByZeroException
now.
\var_dump(-0.0);
(PHP float(-0)), (HHVM float(0)).
Is this related to 4.9.0?
_The hhvm.forcehh INI setting now defaults to true; as all files are now handled as Hack files, this only controls some smaller behaviors which are not to PHP vs Hack: ... the string of -0.0 is now "0" instead of "-0"
@lexidor There's two different issues:
"-0"
when converted to a string. That is issue #7425.-0.0
results in a negative zero, like -1.0 * 0.0
does. That is this issue.It is unclear which of these (or both) the release notes of 4.9.0 are referring to.
In any case, I only opened this issue for the sake of PHP compatibility, and since that has not been a goal for some time it is up to the Hack team what the correct behavior is here.
@jesseschalken I don't know if Hack code has any way of observing the difference between -0.0
and 0.0
anymore now the toString behavior has changed. It would be great is this was transparent to Hack code.
@jesseschalken I don't know if Hack code has any way of observing the difference between
-0.0
and0.0
anymore now the toString behavior has changed.
I don't have a HHVM interpreter in front of me but you could try:
print \bin2hex(\pack("d", 0.0)) . "\n";
print \bin2hex(\pack("d", -0.0)) . "\n";
print \bin2hex(\pack("d", -1.0 * 0.0)) . "\n";
<<__EntryPoint>>
function main(): void {
print \bin2hex(\pack("d", 0.0))."\n"; // 0000000000000000
print \bin2hex(\pack("d", -0.0))."\n"; // 0000000000000000
print \bin2hex(\pack("d", -1.0 * 0.0))."\n"; // 0000000000000080
}
HHVM appears to outsmart you when you ask for -0.0
and gives you 0.0
instead. -1.0 * 0.0
gives -0.0
.
Thanks for your assistance, I'll pass this on to someone who works on the parser, because this is unexpected to say the least.
HHVM Version
Standalone code, or other way to reproduce the problem
Expected result
Actual result
See https://3v4l.org/AnbFm. This is a copy of PHP bug https://bugs.php.net/bug.php?id=52355, which was fixed in 7.0.2. See also #7425.