<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/BitRRotate?action=history&amp;feed=atom</id>
	<title>BitRRotate - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/BitRRotate?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=BitRRotate&amp;action=history"/>
	<updated>2026-10-15T21:39:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.1</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=BitRRotate&amp;diff=46734&amp;oldid=prev</id>
		<title>Necktrox: Added page for bitRRotate</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=BitRRotate&amp;diff=46734&amp;oldid=prev"/>
		<updated>2016-02-21T22:03:08Z</updated>

		<summary type="html">&lt;p&gt;Added page for bitRRotate&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Shared function}}&lt;br /&gt;
&lt;br /&gt;
This functions performs a bitwise circular right-rotation on the integer &amp;#039;&amp;#039;&amp;#039;value&amp;#039;&amp;#039;&amp;#039; by integer &amp;#039;&amp;#039;&amp;#039;n&amp;#039;&amp;#039;&amp;#039; positions.&lt;br /&gt;
See [https://en.wikipedia.org/wiki/Bitwise_operation#Rotate_no_carry Bitwise operation] for more details.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int bitRRotate ( int value, int n )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;value:&amp;#039;&amp;#039;&amp;#039; The value you want to perform the rotation on.&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;n:&amp;#039;&amp;#039;&amp;#039; The amount of positions to rotate the value by.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the circular right-rotated value as &amp;#039;&amp;#039;integer&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds the clientside command &amp;#039;&amp;#039;&amp;#039;/rightrotate [value] [positions = 1]&amp;#039;&amp;#039;&amp;#039;, which will print the result from the function [[bitRRotate]].&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getNumberAsBitString(value)&lt;br /&gt;
    if type(value) ~= &amp;#039;number&amp;#039; then&lt;br /&gt;
        return false&lt;br /&gt;
    else&lt;br /&gt;
        local binary = &amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
        for field = 31, 0, -1 do&lt;br /&gt;
            binary = binary .. bitExtract(value, field)&lt;br /&gt;
&lt;br /&gt;
            if field % 4 == 0 then&lt;br /&gt;
                binary = binary ..&amp;#039; &amp;#039;&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return binary&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;#039;rightrotate&amp;#039;,&lt;br /&gt;
    function (command, value, positions)&lt;br /&gt;
        if type(value) ~= &amp;#039;string&amp;#039; or value:len() == 0 then&lt;br /&gt;
            return outputChatBox(&amp;#039;* Syntax: /rightrotate [value] [positions = 1]&amp;#039;)&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if type(positions) ~= &amp;#039;string&amp;#039; or positions:len() == 0 then&lt;br /&gt;
            positions = 1&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        local result = bitRRotate(tonumber(value), tonumber(positions))&lt;br /&gt;
        local binary = getNumberAsBitString(result)&lt;br /&gt;
&lt;br /&gt;
        outputChatBox(&amp;#039;* Decimal: &amp;#039;.. result ..&amp;#039;, Binary: &amp;#039;.. binary)&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you trigger the command with &amp;#039;&amp;#039;&amp;#039;/rightrotate 0xFF0000 16&amp;#039;&amp;#039;&amp;#039; you will receive as response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
* Decimal: 255, Binary: 0000 0000 0000 0000 0000 0000 1111 1111 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Bit_functions}}&lt;/div&gt;</summary>
		<author><name>Necktrox</name></author>
	</entry>
</feed>