harangzsolt33 has asked for the wisdom of the Perl Monks concerning the following question:
The result of both of these calculations below should be : 0x0000000133000000 which equals 5,150,605,312. Now, since I'm using a 32-bit software, the result ought to be 0x33000000 which equals 855,638,016. But I get neither of those!!! Why?
printf("\nLINE 1: 855638016 == %d", 0x34000000 + 0xFF000000);
print "\nLINE 2: 855638016 == ", (872415232 + 4278190080) & 0xFFFFFFFF;
This is what TinyPerl 5.8 on WinXP prints on my computer screen:
LINE 1: 855638016 == -1
LINE 2: 855638016 == 4294967295
(Notice that both of these numbers are the same thing. -1 = 0xFFFFFFFF = 4294967295. But on the first line, I get -1, and on the second line I get the positive number in base 10. This is totally unacceptable! What is going on here???
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl arithmetic is killing me! HELP!
by syphilis (Archbishop) on Nov 07, 2018 at 12:39 UTC | |
by marto (Cardinal) on Nov 07, 2018 at 12:46 UTC | |
by ikegami (Patriarch) on Nov 07, 2018 at 13:34 UTC | |
by syphilis (Archbishop) on Nov 08, 2018 at 07:58 UTC | |
by ikegami (Patriarch) on Nov 08, 2018 at 08:06 UTC | |
by syphilis (Archbishop) on Nov 08, 2018 at 09:13 UTC | |
| |
|
Re: perl arithmetic is killing me! HELP!
by ikegami (Patriarch) on Nov 07, 2018 at 13:30 UTC | |
by harangzsolt33 (Deacon) on Nov 07, 2018 at 15:50 UTC | |
by ikegami (Patriarch) on Nov 07, 2018 at 17:38 UTC | |
|
Re: perl arithmetic is killing me! HELP!
by LanX (Saint) on Nov 06, 2018 at 23:12 UTC | |
|
Re: perl arithmetic is killing me! HELP!
by Anonymous Monk on Nov 06, 2018 at 23:10 UTC | |
by harangzsolt33 (Deacon) on Nov 06, 2018 at 23:57 UTC |