Connect with Facebook Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-31-2008, 02:50 PM
Learning Programmer
 
Join Date: Jul 2008
Posts: 51
Rep Power: 4
MrGamma is on a distinguished road
Default 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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-31-2008, 03:05 PM
WingedPanther's Avatar   
Super Moderator
 
Join Date: Jul 2006
Age: 36
Posts: 8,079
Blog Entries: 48
Rep Power: 20
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default 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 | Linux Forum
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-31-2008, 03:09 PM
Learning Programmer
 
Join Date: Jul 2008
Posts: 51
Rep Power: 4
MrGamma is on a distinguished road
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Vs AJAX Megrisoft AJAX 28 05-27-2009 12:24 PM
Beginning PHP Xav PHP Forum 109 06-12-2008 11:06 AM
PHP accessing through remotely javascript from another website deny MarketPlace 4 01-28-2008 08:02 AM
Javascript accessing PHP Ronin JavaScript and CSS 0 11-08-2006 06:29 PM


All times are GMT -5. The time now is 09:27 PM.

Freelance Jobs

XML/XSL: Need code for Book with Chapers using XML
Create an XML file for a book of your creation, and a basic CSS file that will format it to display ...
Earn: $40.00


C++/C: Simple firework cue sequencer
What I require is a rework of a simple cue sequencer. I have a piece of hardware (an Arduino boar...
Earn: $50.00


HTML/XHTML: Menu Rework - ASCIIBin
I'm placing this in the HTML/XHTML section of the Freelance site but you are not limited to HTML. Wh...
Earn: $20.00



CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%

Ads