Re: Unsigned Problems Revisited
| From: | Yasuo Ohgaki | Date: | Tue, 22 Oct 2002 20:46:24 +0000 |
| Subject: | Re: Unsigned Problems Revisited | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-89934@lists.php.net to get a copy of this message | ||
Jason T. Greene wrote:
> After being bit by the unsigned number problems in php again, I have
> decided to focus on getting them quickly resolved. After spending some
> time researching, I have come up with a list of possible fixes ranked in
> order of my preference. Please send me your arguments, comments, etc
>
snip
> 3. Implement Unsigned Data types
> ---------------------------------
>
> It is possible to implement a uint data type, which could be made
> available by either using settype(), or (uint), and by certain scenarios
> decided by the engine. Ambiguities are solved by the following rule: All
> mathematical operations performed on an unsigned type will result in an
> unsigned type, unless overflow occurs. Floating point numbers, if
> positive, could be converted to an unsigned type before right shift
> occurs. The following code demonstrates this options:
>
> <?php
>
> $b = (uint) 1;
>
> //Set b = 1
> $b = (1 << 31) >> 31;
>
> ?>
>
I vote for this.
Unsigned int(long) is useful not only for unsigned shift,
but also other modules/functions requires unsigned int to
work right. e.g. PostgreSQL OID, ip2long.
--
Yasuo Ohgaki