Re: Integer casts broken or...?
| From: | Brian Moon | Date: | Mon, 14 May 2001 19:18:51 +0000 |
| Subject: | Re: Integer casts broken or...? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-55230@lists.php.net to get a copy of this message | ||
This is correct. The type casting converts the string into its integer
value. If there is a non-numeric character in the string, it stops at that
point. So "09" is 9 and "09t" is 9 but "0t9" is 0.
Brian Moon
----------------------------------------------------------------------
dealnews.com, Inc.
Makers of dealnews, dealmac
http://dealnews.com/ | http://dealmac.com/
----- Original Message -----
From: "Lars Torben Wilson" <torben@php.net>
To: <php-dev@lists.php.net>
Sent: Monday, May 14, 2001 1:29 PM
Subject: [PHP-DEV] Integer casts broken or...?
>
> Type casting to int from string works only for decimal values--is this
> by design? Example:
>
> echo (int) '09' . ', ' . (int) '0x24';
>
> ...produces:
>
> 9, 0
>
> which seems intuitively wrong (I'd have expected 0, 36).
>
> Is this wrong, or should I just document it?
>
>
> Thanks,
>
> Torben
>
> --
> Torben Wilson <torben@php.net>
> http://www.thebuttlesschaps.com
> +1.604.709.0506
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>