Re: bitwise Operators
Many Thanks, Sean. :-) No problem.. Hopefully others will find them useful and save them from the same headaches that I've had to go through.. You are using this code in the SHA-1 algorithm, Right? Yes, hopefully now I can get it done now and easily track down any bugs that there may be.. i'm working in a md4digest handler for Good luck and have fun =) _ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: bitwise Operators
Sean- Thursday, November 24, 2005, 2:34:34 AM, you wrote: > Due to the fact that the bitwise operators in RunRev do not work on signed > integers, nor do they have shiftLeft and shiftRight, I decided to write my > own, so here they are.. I'll put them on my website another day.. As always, > these are released into the Public Domain.. Any questions, comments, > suggestions feel free to email me.. Thanks. I had tried these myself and got bogged down with what happens when one factor is negative and the other isn't. -- -Mark Wieder [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: bitwise Operators
om Thu, 24 Nov 2005 Sean Shao wrote: > Due to the fact that the bitwise operators > in RunRev do not work on signed integers, > nor do they have shiftLeft and shiftRight, > I decided to write my own, so here they are.. Excellent! Many Thanks, Sean. :-) > I'll put them on my website another day.. > As always, these are released > into the Public Domain.. This is great, but when i use your handlers, i'll include your name and website in your code like this: function bitwiseAnd p1, p2 -- in other languages ( 9 & 2 ) -- By Sean Shao, (and name of your website) > Any questions, comments, suggestions > feel free to email me.. You are using this code in the SHA-1 algorithm, Right? i'm working in a md4digest handler for implementing a rSync client in RunRev. Hope that it'll be fast enough to be usable. Thanks again for sharing your work! alejandro Visit my site: http://www.geocities.com/capellan2000/ __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
bitwise Operators
Due to the fact that the bitwise operators in RunRev do not work on signed integers, nor do they have shiftLeft and shiftRight, I decided to write my own, so here they are.. I'll put them on my website another day.. As always, these are released into the Public Domain.. Any questions, comments, suggestions feel free to email me.. All parameters are signed integers (ie. 200, -9, 32) function bitwiseAnd p1, p2 -- in other languages ( 9 & 2 ) local tP1Neg, tP2Neg if (p1 < 0) then put bitNot abs(p1) +1 into p1 put TRUE into tP1Neg end if if (p2 < 0) then put bitNot abs(p2) +1 into p2 put TRUE into tP2Neg end if if (tP1Neg) AND (tP2Neg) then return 0 - bitNot ((p1 bitAnd p2) -1) else return p1 bitAnd p2 end bitwiseAnd function bitwiseOr p1, p2 -- in other languages ( 9 | 2 ) local tP1Neg, tP2Neg if (p1 < 0) then put bitNot abs(p1) +1 into p1 put TRUE into tP1Neg end if if (p2 < 0) then put bitNot abs(p2) +1 into p2 put TRUE into tP2Neg end if if (tP1Neg) OR (tP2Neg) then return 0 - bitNot ((p1 bitOr p2) -1) else return p1 bitOr p2 end bitwiseOr function bitwiseXor p1, p2 -- in other languages ( 9 ^ 2 ) local tP1Neg, tP2Neg if (p1 < 0) then put bitNot abs(p1) +1 into p1 put TRUE into tP1Neg end if if (p2 < 0) then put bitNot abs(p2) +1 into p2 put TRUE into tP2Neg end if if (tP1Neg) AND (tP2Neg) then return p1 bitXor p2 else if (tP1Neg) OR (tP2Neg) then return 0 - bitNot ((p1 bitXor p2) -1) else return p1 bitXor p2 end bitwiseXor function bitwiseNot p1 -- in other languages ( ~9 ) return 0 - (p1 + 1) end bitwiseNot ### parameter p2 is the amount to shift over function bitwiseShiftLeft p1, p2 -- in other languages ( 9 << 2) return p1 * (2 ^ p2) end bitwiseShiftLeft function bitwiseShiftRight p1, p2 -- in other languages ( 9 >> 2 ) if (p2 > 0) then return trunc(p1 / (2 ^ p2)) if (p2 = 0) then return p1 if (p1 < 0) then return trunc(p1 / (2 ^ p2)) -1 end bitwiseShiftRight function bitwiseShiftRightZero p1, p2 -- in other languages ( 9 >>> 2 ) if (p1 > 0) then return trunc(p1 / (2 ^ p2)) if (p2 = 0) then return p1 if (p1 < 0) then put baseConvert(bitNot abs(p1) +1, 10, 2) into p1 repeat p2 delete char -1 of p1 put 0 before p1 end repeat return baseConvert(p1, 2, 10) end if end bitwiseShiftRightZero _ Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/ ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: working with binary numbers with bitwise operators
On Saturday, May 29, 2004, at 11:33 PM, Alejandro Tejada wrote: If i convert this 48 bit binary number in decimal then i get a negative number: put baseconvert (01001100111110101010101101100101110111010101,2,10) results in -2864078293 There may be two factors here. Bugzilla 38 describes a problem in base conversions to base 10. The baseconvert() function uses a 32 bit environment. and i've noticed that the function "bitnot" produces this result: put bitnot 35 produces 4294967260 put bitnot 52 produces 4294967243 The bit-logical operators use a 32-bit environment. If you need more than 32 bits you might need to build up multiple 32-bit numbers or (as you did for shifting) use strings of 0 and 1. If you need to use bit shifting (and rotating) with the bit logical operators, you might want to make the number version. Dar Scott ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
working with binary numbers with bitwise operators
Hi Developers, I've been working with bitwise operators in binary numbers of 48 bits like this: "01001100111110101010101101100101110111010101" and noticed the following: If i convert this 48 bit binary number in decimal then i get a negative number: put baseconvert (01001100111110101010101101100101110111010101,2,10) results in -2864078293 and i've noticed that the function "bitnot" produces this result: put bitnot 35 produces 4294967260 put bitnot 52 produces 4294967243 Are these the expected results? There's no left and right bitshift operators in RR/MC so i'm using this function: Function bitshiftleft binarynumber,numberofbytestoshift put the number of chars of binarynumber into binlength repeat numberofbytestoshift put "0" after binarynumber end repeat delete char 1 to numberofbytestoshift of binarynumber return binarynumber end bitshiftleft Function bitshiftright binarynumber,bytestoshift put the number of chars of binarynumber into binlength repeat bytestoshift put "0" before binarynumber end repeat delete char -(bytestoshift) to -1 of binarynumber return binarynumber end bitshiftright The operators bitor, bitand, bitxor works as expected, but i'm not fully aware of all it's features or limitations. If you had worked before with binary numbers and bitwise operators, i'll be highly gratefull of your help. Thanks in advance! al = Visit my site: http://www.geocities.com/capellan2000/ Search the mail list: http://mindlube.com/cgi-bin/search-use-rev.cgi __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution