As far as I know, we made it that way in order to enforce an int return type all the time. int(-1) is indeed the sensible value for this. (Mainly int(0) does not work because it'd mean equality and so we're left with int(-1) and int(1).)
Just because other comparison ops already return a bool, we can return bool(false) there. Bob > Am 15.06.2015 um 21:44 schrieb Dmitry Stogov <dmi...@zend.com>: > > Hi, > > I found a problem with spaceship operator. > It doesn't define result for comparison with NaN. > > $ sapi/cli/php -r 'var_dump(sqrt(-1) <=> 0);' > int(-1) > $ sapi/cli/php -r 'var_dump(0 <=> sqrt(-1));' > int(-1) > > $ sapi/cli/php -r 'var_dump(0 < sqrt(-1));' > bool(false) > > all other comparison operators return "false" as well. > > Thanks. Dmitry. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php