+ Reply to Thread
Results 1 to 3 of 3

Thread: Bit Wise JavaScript and PHP

  1. #1
    Learning Programmer MrGamma is on a distinguished road
    Join Date
    Jul 2008
    Posts
    51

    Bit Wise JavaScript and PHP

    I'm having an issue trying to figure out why in javascript.

    1532515508 ^ -3955803181 = 1332703079

    but in php it equals...

    1532515508 ^ -3955803181 = -614968140

    Does anybody know why?

  2. #2
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,680
    Blog Entries
    57

    Re: Bit Wise JavaScript and PHP

    It depends on the number of bits used to represent those values. If they are using a different number of bits, you will get different results.
    CodeCall Blog | CodeCall Wiki | Shareware
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  3. #3
    Learning Programmer MrGamma is on a distinguished road
    Join Date
    Jul 2008
    Posts
    51

    Re: Bit Wise JavaScript and PHP

    Never mind... JavaScript was using unsigned integers while Php was using Signed...

    At least I think that's what was happening... This fixed it...

    Code:
    function _unSign($i1) {
        if(0x7fffffff < $i1) {
            $i1 -= 0xffffffff + 1.0;
        }elseif (-0x80000000 > $i1) {
            $i1 += 0xffffffff + 1.0;
        }
        return $i1;
    }
    _unSign(1532515508) ^ _unSign(-3955803181) = 1332703079

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. PHP Vs AJAX
    By Megrisoft in forum AJAX
    Replies: 35
    Last Post: 10-04-2009, 04:02 AM
  2. Beginning PHP
    By Xav in forum PHP Forum
    Replies: 109
    Last Post: 06-12-2008, 11:06 AM
  3. Replies: 4
    Last Post: 01-28-2008, 08:02 AM
  4. Javascript accessing PHP
    By Ronin in forum JavaScript and CSS
    Replies: 0
    Last Post: 11-08-2006, 06:29 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts