<?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-05-02T15:51:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</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 '''value''' by integer '''n''' 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;
*'''value:''' The value you want to perform the rotation on.&lt;br /&gt;
*'''n:''' 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 ''integer''.&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 '''/rightrotate [value] [positions = 1]''', 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) ~= 'number' then&lt;br /&gt;
        return false&lt;br /&gt;
    else&lt;br /&gt;
        local binary = ''&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 ..' '&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('rightrotate',&lt;br /&gt;
    function (command, value, positions)&lt;br /&gt;
        if type(value) ~= 'string' or value:len() == 0 then&lt;br /&gt;
            return outputChatBox('* Syntax: /rightrotate [value] [positions = 1]')&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if type(positions) ~= 'string' 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('* Decimal: '.. result ..', Binary: '.. 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 '''/rightrotate 0xFF0000 16''' 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>