Today i was working on a PHP project and came across this code behaviour
<?php
$x = 5.5;
$y = 0;
echo $z = floor($x * $y * -1);
?>
This gave the output of -0
.
Can anyone shed light on why this echoes -0
. But I expected 0
Only when adding floor this appears to happen.
I tried the same in java.
class Sample {
public static void main(String[] args) {
float x =5.5f;
int y = 0;
System.out.println(Math.floor(x*y*-1));
}
}
This also prints -0.0
.