<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/BitArShift?action=history&amp;feed=atom</id>
	<title>BitArShift - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/BitArShift?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=BitArShift&amp;action=history"/>
	<updated>2026-10-05T00:24:45Z</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=BitArShift&amp;diff=46743&amp;oldid=prev</id>
		<title>Necktrox: Grammar</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=BitArShift&amp;diff=46743&amp;oldid=prev"/>
		<updated>2016-02-22T01:10:24Z</updated>

		<summary type="html">&lt;p&gt;Grammar&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:10, 22 February 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l2&quot;&gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Shared function}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Shared function}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This functions performs an arithmetic shift on the integer &#039;&#039;&#039;value&#039;&#039;&#039; by integer &#039;&#039;&#039;n&#039;&#039;&#039; positions. In &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;a &lt;/del&gt;&#039;&#039;arithmetic shift&#039;&#039;, zeros are shifted in to replace the discarded bits. In a &#039;&#039;right arithmetic&#039;&#039; shift, the [https://en.wikipedia.org/wiki/Sign_bit sign bit] is shifted in on the left, thus preserving the sign of the operand.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This functions performs an arithmetic shift on the integer &#039;&#039;&#039;value&#039;&#039;&#039; by integer &#039;&#039;&#039;n&#039;&#039;&#039; positions. In &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;an &lt;/ins&gt;&#039;&#039;arithmetic shift&#039;&#039;, zeros are shifted in to replace the discarded bits. In a &#039;&#039;right arithmetic&#039;&#039; shift, the [https://en.wikipedia.org/wiki/Sign_bit sign bit] is shifted in on the left, thus preserving the sign of the operand.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See [https://en.wikipedia.org/wiki/Bitwise_operation#Arithmetic_shift Bitwise operation] for more details.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See [https://en.wikipedia.org/wiki/Bitwise_operation#Arithmetic_shift Bitwise operation] for more details.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-wiki_dev_:diff:1.41:old-46741:rev-46743:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Necktrox</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=BitArShift&amp;diff=46741&amp;oldid=prev</id>
		<title>Necktrox: Added page for bitArShift</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=BitArShift&amp;diff=46741&amp;oldid=prev"/>
		<updated>2016-02-21T22:40:48Z</updated>

		<summary type="html">&lt;p&gt;Added page for bitArShift&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 an arithmetic shift 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. In a &amp;#039;&amp;#039;arithmetic shift&amp;#039;&amp;#039;, zeros are shifted in to replace the discarded bits. In a &amp;#039;&amp;#039;right arithmetic&amp;#039;&amp;#039; shift, the [https://en.wikipedia.org/wiki/Sign_bit sign bit] is shifted in on the left, thus preserving the sign of the operand.&lt;br /&gt;
See [https://en.wikipedia.org/wiki/Bitwise_operation#Arithmetic_shift 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 bitArShift ( 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 arithmetic shift on.&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;n:&amp;#039;&amp;#039;&amp;#039; The amount of positions to shift the value by.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the arithmetic shifted 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;/arshift [value] [positions = 1]&amp;#039;&amp;#039;&amp;#039;, which will print the result from the function [[bitArShift]].&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;arshift&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: /arshift [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 = bitArShift(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;/arshift 0xF0 4&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;/arshift 0xF0 -4&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: 15,   Binary: 0000 0000 0000 0000 0000 0000 0000 1111&lt;br /&gt;
* Decimal: 3840, Binary: 0000 0000 0000 0000 0000 1111 0000 0000&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>