dec*(), *dec(), base_convert() and negative numbers

From: Date: Wed, 26 Jul 2006 09:26:53 +0000
Subject: dec*(), *dec(), base_convert() and negative numbers
Groups: php.internals 
Request: Send a blank email to internals+get-24981@lists.php.net to get a copy of this message
Hi all, I was just updating the dec[bin|hex|oct] functions to convert numbers >= 2^32 since the [bin|hex|oct]dec counterparts were updated way back in PHP 4.1. My question is if negative numbers should be handled any differently. Now negative longs are converted to unsigned which gives a weird result for regular users IMO. The *dec() functions ignore negative strings. Because of the way base_convert() works, if you pass a negative number (gets converted to string), the result will be from the absolute value instead of what you get with dec*(). *) Should the dec*() functions continue to convert negative longs to unsigned and use absolute value for doubles? *) Should absolute value always be used, like with base_convert()? *) Should everything be changed to support negative numbers going both directions (to or from base)? Thanks, Matt

« previous php.internals (#24981) next »