Hi again, I realize I might not get any answer about updating these little ol' functions :-/, but it'd be nice to hear something one way or the other so I can submit an acceptable patch with correct behavior.
After thinking about it more, are negative numbers even "officially supported" with the dec[bin|hex|oct] functions? You won't get anything close to the original back with *dec(dec*(-123)). Since base_convert() uses the number's absolute value, I'm thinking the only reason for using "unsigned long" for the dec*() functions is to handle cases where a PHP double is between LONG_MAX and ULONG_MAX. If so, I think absolute value can be used everywhere. Or again, should I update the functions to correctly accept and return negative values? But I'm not sure if negative bin/hex/oct strings are desired (semantically). Thanks for any simple guidance! Matt ----- Original Message ----- From: "Matt W" Sent: Wednesday, July 26, 2006 > 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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php