Is minus (negative) zero equivalent to 0 in PHP?
In PHP, there is no real difference:
Float:
php > $negZ = -0.0;
php > $posZ = +0.0;
php > var_dump($negZ == $posZ, $negZ === $posZ);
bool(true)
bool(true)
Int:
php > $negZ = -0;
php > $posZ = +0;
php > var_dump($negZ == $posZ, $negZ === $posZ);
bool(true)
bool(true)
I just asked myself the same question and thought 0 === -0 is true:
How to reproduce:
<?php
$sum = 1.0000001;
$val = 1.00;
$a = round($val - $sum,2);
var_dump($a, $a === 0);
float(-0)
bool(false)