|
Posted by Tim Roberts on 01/24/06 08:37
"Jim Michaels" <jmichae3@yahoo.com> wrote:
>
>How do you know the PHP lexical analyzer or parser is going to lop off a bit
>for you? what if it does something else?
PHP does not handle integers larger than "long" on its machine. Thus, on a
32-bit machine, I KNOW it's going to lop off a bit.
>your number in hex is 0xFFFF FFFE E58D 315F ^ 0x0000 0000 0000 AB26=0xFFFF
>FFFF 8000 AB26
No, that would be my number in a 64-bit variable. My description below
specifically mentions a 32-bit variable, as the OP was using.
>2's complement numbers in hex are represented differently in binary...
No, they aren't. The numbers are ALL binary. Whether I print them in
binary or hex or decimal is irrelevant to the way they are processed.
However, the SIZE of the variable is important.
>this is from pcalc, a program from analogx.com (64-bit programmer's
>calculator)
Right. That's the result you'd get from a 64-bit processor. PHP on a
32-bit processor will produce the result I described.
>"Tim Roberts" <timr@probo.com> wrote in message:
>> "Chung Leong" <chernyshevsky@hotmail.com> wrote:
>>>
>>>How is -4,738,698,913 ^ 43814 = -443,704,711 correct?
>>
>> First, answer this question: how can you squeeze -4,738,698,913 into a
>> 32-bit variable?
>>
>> 4,738,698,913 would be 1_1A72_CEA1 in hex, but that needs 33 bits. If you
>> truncate that to 32 bits, you get 1A72_CEA1. Xor that with 43,814, which
>> is AB26 in hex, and you get 1A72_6587, which just happens to be
>> 443,704,711.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Navigation:
[Reply to this message]
|