Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #4491

Re: Implied cast differs from explicit cast

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.php
Subject Re: Implied cast differs from explicit cast
Date Tue, 17 Jan 2012 06:59:10 +0100
Organization A noiseless patient Spider
Lines 56
Message-ID <4F150E2E.80003@arnowelzel.de> (permalink)
References <4f1378ee$0$16741$882e7ee2@usenet-news.net> <jevvqe$1gk$1@dont-email.me> <4f139498$0$16818$882e7ee2@usenet-news.net> <jf18lk$na6$1@news.albasani.net> <jf19m7$rbt$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
Injection-Info mx04.eternal-september.org; posting-host="6X7XqsRC4GQAmI7FQ3v4Fw"; logging-data="1447"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nr2+R4rld5eNmjkMDI72m2CZUrRjhMF0="
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1
In-Reply-To <jf19m7$rbt$1@dont-email.me>
Cancel-Lock sha1:4OObEIZkWUBYWUEhi2+A4gWa4jI=
Xref x330-a1.tempe.blueboxinc.net comp.lang.php:4491

Show key headers only | View raw


Jerry Stuckle, 2012-01-16 14:45:

> On 1/16/2012 8:28 AM, The Natural Philosopher wrote:
>> lb wrote:
>>> jstucklex@attglobal.net wrote:
>>>> ...
>>>> No, it is not. '0x12' is a hex number, not an integer. (int)'0x12'
>>>> converts this correctly to 0.
>>
>> Looks like Jerry doesn't know what an integer is either.
>>
>> A hex number of course *is* an integer, unless its a hex representation
>> of floating point.
>>
>> Killfile the prat like I have.
>>
>>
> 
> 0x12 is not an integer.  It is a hexadecimal value.

No, 0x12 (and *not* "0x12") is the hexadecimal *representation* of the
value 18. There is no thing like "hexadecimal value" and "0x12" is a
*string* and not a number at all.

In fact PHP only knows to types of numbers: integers and floating point.
There is no "hexadecimal" data type.

> It can have the same bit pattern as an integer - but it can also have
> the same bit pattern as a character (Ctrl-R, to be exact).

Which also applies to the value 18 - this can also be the value of a
character.

Example:

<?php
$a = 0x12;

print $a;
?>

Result:

Value of $a: 18, type of $a: integer

So you see 0x12 *is* an integer.

Of course "0x12" (including the quotes) is a string and *converting* the
string to a number may need attention to the representation of the
number within the string.


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Implied cast differs from explicit cast lb <lb2048@pobox.com.delete> - 2012-01-16 01:10 +0000
  Re: Implied cast differs from explicit cast Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-15 20:51 -0500
    Re: Implied cast differs from explicit cast lb <lb2048@pobox.com.delete> - 2012-01-16 03:08 +0000
      Re: Implied cast differs from explicit cast Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-15 22:39 -0500
        Re: Implied cast differs from explicit cast Arno Welzel <usenet@arnowelzel.de> - 2012-01-16 08:42 +0100
          Re: Implied cast differs from explicit cast Curtis Dyer <dyer85@gmail.com> - 2012-01-16 09:04 +0000
          Re: Implied cast differs from explicit cast Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-16 08:25 -0500
            Re: Implied cast differs from explicit cast "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-01-16 19:51 +0100
      Re: Implied cast differs from explicit cast The Natural Philosopher <tnp@invalid.invalid> - 2012-01-16 13:28 +0000
        Re: Implied cast differs from explicit cast Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-16 08:45 -0500
          Re: Implied cast differs from explicit cast Arno Welzel <usenet@arnowelzel.de> - 2012-01-17 06:59 +0100
            Re: Implied cast differs from explicit cast Arno Welzel <usenet@arnowelzel.de> - 2012-01-17 07:00 +0100
              Re: Implied cast differs from explicit cast Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-17 08:17 -0500
            Re: Implied cast differs from explicit cast Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-17 08:16 -0500
              Re: Implied cast differs from explicit cast Arno Welzel <usenet@arnowelzel.de> - 2012-01-19 13:36 +0100
                Re: Implied cast differs from explicit cast Arno Welzel <usenet@arnowelzel.de> - 2012-01-19 13:39 +0100
                Re: Implied cast differs from explicit cast Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-19 09:06 -0500
                Re: Implied cast differs from explicit cast Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-19 09:05 -0500
                Re: Implied cast differs from explicit cast The Natural Philosopher <tnp@invalid.invalid> - 2012-01-19 15:01 +0000
                Re: Implied cast differs from explicit cast Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-19 14:41 -0500
  Re: Implied cast differs from explicit cast "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-01-16 09:49 +0100
  Re: Implied cast differs from explicit cast "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-01-16 11:48 +0100
    Re: Implied cast differs from explicit cast lb <lb2048@pobox.com.delete> - 2012-01-17 02:35 +0000

csiph-web