FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Implied cast differs from explicit cast
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Implied cast differs from explicit cast [message #176687 is a reply to message #176682] Tue, 17 January 2012 13:17 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 1/17/2012 1:00 AM, Arno Welzel wrote:
> Arno Welzel, 2012-01-17 06:59:
>
>> Jerry Stuckle, 2012-01-16 14:45:
>>
>>> On 1/16/2012 8:28 AM, The Natural Philosopher wrote:
>>>> lb wrote:
>>>> > jstucklex(at)attglobal(dot)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
>
> Sorry - the example was not complete:
>
> <?php
> $a = 0x12;
>
> $a = intval($a, 16);
>
> print 'Value of $a: ' . $a . ', type of $a: ' . gettype($a);
> ?>
>
>
>

Sure. You explicitly converted the hexadecimal value to an integer.
What do you expect?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Open Source Development
Next Topic: error from phpadmin
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 03 01:22:36 GMT 2024

Total time taken to generate the page: 0.04536 seconds