Hi Michael,

----- Original Message -----
From: "Michael Wallner"
Sent: Thursday, July 27, 2006


> Matt W wrote:
>
> > That's why I'm assuming negative numbers aren't "really" supported
> > now (not in any form with base_convert()), but it's simply a side
> > effect of wanting to handle *positive* numbers between LONG_MAX and
> > ULONG_MAX.  e.g. when doing dechex(4294967173) that's a PHP double,
> > but it gets converted to long (becomes -123), and finally unsigned
> > long (recovering 4294967173).  IOW, after convert_to_long() in dec*()
> > it doesn't know if -123 or 4294967173 was passed.  Make sense?
> > (Actually, it doesn't, that's my point. :-))
>
> For your computer 0xffffff85 is -123 and 4294967173.  It's just how
> you look on it.

Oh, I know.  But that still doesn't answer the question of how to handle
negative *double's*.

> > So after more thinking, I figure when upgrading dec*() to handle any
> > number, absolute value should be used (then int(123) would be
> > returned in my example).  Unless the all the functions are changed to
> > properly accept/return negatives... I personally don't care either
> > way on that.
>
> No way. Why should hexdec(dechex(-123)) return +123?

Because it makes more sense to users than 4294967173? :-)  They don't care
what's stored as 0xffffff85, blah blah, just what they actually see.  Oh,
and doing the same to/from using -123 and base_convert(), you'll get +123!

IMO, it was *wrong* to convert a negative to unsigned long.  Absolute value
should've been used like with base_convert (though that may be by chance
rather than design :-)).  Of course, it could all be very
consistent/logical, to me, by accepting/returning negatives.  But what are
the thoughts on negative base 2-36 strings?  No-no's?

> -- 
> Michael

I appreciate your replies.  I'll be gone for a while now, so I won't be
bothering you with another e-mail. :-P


Matt

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to