Hi again, OK, after my last message, I found when the dec*() functions started converting to unsigned long (Bug #6761). To make dechex(~8) etc. work. Now I know that behavior can't change. :-) Hopefully this is my last e-mail about this, if I can please find out about 2 simple things:
1) How should a negative *double*, whether it's < LONG_MIN or typecast (double) -123, be handled? *) Continue converting to long/unsigned long, like now? *) Use absolute value? (Only if double!) Either way, base_convert() should continue to use absolute value for all numbers, I assume. 2) CAN base_convert() be changed to return an actual number instead of a string if tobase=10? Seems a waste to convert a base 10 result to string like now... :-? Thanks! Matt ----- Original Message ----- From: "Matt W" Sent: Friday, July 28, 2006 > Hi, > > More thoughts... > > I forgot to say last time that the manual doesn't mention the dec*() > parameter being treated as unsigned. The *printf() specifiers b/o/x/X > already do this (although the manual doesn't say that either, only for %u). > > After looking through the comments for dechex(), there's another thing: 32- > vs 64-bit. On a 64-bit system, I think dechex(-123) would currently return > ffffffffffffff85, which when reversed on my system gives > > php -d precision=20 -r "var_dump(hexdec('ffffffffffffff85'));" > float(18446744073709552000) > > Are you saying, Michael, that the negative behavior should be left as-is for > people to see "how the number is stored by the computer?" I think just > using the *printf() specifiers would better. IMO, the dec*() and *dec() > functions should work the same as the corresponding to/from base with > base_convert() (absolute value), and vice-versa. > > BTW, can base_convert() simply return an actual number instead of a string > when tobase=10? Again, to be the same as *dec() and avoid conversion to > string if it's just going to be used in numeric context. > > > Matt -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php