<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.hard-light.org/index.php?action=history&amp;feed=atom&amp;title=Tutorial_-_Bitwise_Operations</id>
	<title>Tutorial - Bitwise Operations - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.hard-light.org/index.php?action=history&amp;feed=atom&amp;title=Tutorial_-_Bitwise_Operations"/>
	<link rel="alternate" type="text/html" href="https://wiki.hard-light.org/index.php?title=Tutorial_-_Bitwise_Operations&amp;action=history"/>
	<updated>2026-11-15T10:06:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://wiki.hard-light.org/index.php?title=Tutorial_-_Bitwise_Operations&amp;diff=44190&amp;oldid=prev</id>
		<title>AdmiralRalwood at 23:49, 5 August 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.hard-light.org/index.php?title=Tutorial_-_Bitwise_Operations&amp;diff=44190&amp;oldid=prev"/>
		<updated>2014-08-05T23:49:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&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 23:49, 5 August 2014&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-l11&quot;&gt;Line 11:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&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;In our traditional base-10 math, if we have the number 152, we could break it up into 100 + 50 + 2. We could then express each of those numbers as a number times a power of ten. So 152 = 100 + 50 + 2 = (1 x 10^2) + (5 x 10^1) + (2 x 10^0). To express that we can just go 1 5 2. Which is stupidly obvious.&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;In our traditional base-10 math, if we have the number 152, we could break it up into 100 + 50 + 2. We could then express each of those numbers as a number times a power of ten. So 152 = 100 + 50 + 2 = (1 x 10^2) + (5 x 10^1) + (2 x 10^0). To express that we can just go 1 5 2. Which is stupidly obvious.&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;What if we&#039;re restricted to base 2 (aka binary, just a 1 or 0, like computers) and have the number 12? Powers of 2 are 1, 2, 4, 8, 16, 32, 64 … etc etc. So to get 12 out of that we could just go 8 + 4. So our base 2 number would look like (1x2^3) + (1x2^2) + (0x2^1) + (0x2^0). Or just 1 1 0 0. That 12 is actually being &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;store &lt;/del&gt;as 1100 inside the computer program.&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;What if we&#039;re restricted to base 2 (aka binary, just a 1 or 0, like computers) and have the number 12? Powers of 2 are 1, 2, 4, 8, 16, 32, 64 … etc etc. So to get 12 out of that we could just go 8 + 4. So our base 2 number would look like (1x2^3) + (1x2^2) + (0x2^1) + (0x2^0). Or just 1 1 0 0. That 12 is actually being &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;stored &lt;/ins&gt;as 1100 inside the computer program.&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;&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;==Using in FRED==&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;==Using in FRED==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>AdmiralRalwood</name></author>
	</entry>
	<entry>
		<id>https://wiki.hard-light.org/index.php?title=Tutorial_-_Bitwise_Operations&amp;diff=44179&amp;oldid=prev</id>
		<title>Goober5000: /* Bitwise Basics */  and again</title>
		<link rel="alternate" type="text/html" href="https://wiki.hard-light.org/index.php?title=Tutorial_-_Bitwise_Operations&amp;diff=44179&amp;oldid=prev"/>
		<updated>2014-08-04T05:37:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Bitwise Basics: &lt;/span&gt;  and again&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&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 05:37, 4 August 2014&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-l9&quot;&gt;Line 9:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 9:&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;Huh?!&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;Huh?!&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;In our traditional base-10 math, if we have the number 152, we could break it up into 100 + 50 + 2. We could then express each of those numbers as a number times a power of ten. So 152 = 100 + 50 + 2 = (1 x 10^2) + (5 x 10^1) + (&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0 &lt;/del&gt;x 10^0). To express that we can just go 1 5 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0&lt;/del&gt;. Which is stupidly obvious.&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;In our traditional base-10 math, if we have the number 152, we could break it up into 100 + 50 + 2. We could then express each of those numbers as a number times a power of ten. So 152 = 100 + 50 + 2 = (1 x 10^2) + (5 x 10^1) + (&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;2 &lt;/ins&gt;x 10^0). To express that we can just go 1 5 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;2&lt;/ins&gt;. Which is stupidly obvious.&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;&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;What if we&amp;#039;re restricted to base 2 (aka binary, just a 1 or 0, like computers) and have the number 12? Powers of 2 are 1, 2, 4, 8, 16, 32, 64 … etc etc. So to get 12 out of that we could just go 8 + 4. So our base 2 number would look like (1x2^3) + (1x2^2) + (0x2^1) + (0x2^0). Or just 1 1 0 0. That 12 is actually being store as 1100 inside the computer program.&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;What if we&amp;#039;re restricted to base 2 (aka binary, just a 1 or 0, like computers) and have the number 12? Powers of 2 are 1, 2, 4, 8, 16, 32, 64 … etc etc. So to get 12 out of that we could just go 8 + 4. So our base 2 number would look like (1x2^3) + (1x2^2) + (0x2^1) + (0x2^0). Or just 1 1 0 0. That 12 is actually being store as 1100 inside the computer program.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Goober5000</name></author>
	</entry>
	<entry>
		<id>https://wiki.hard-light.org/index.php?title=Tutorial_-_Bitwise_Operations&amp;diff=44178&amp;oldid=prev</id>
		<title>Goober5000: /* Bitwise Basics */  Axem can&#039;t math</title>
		<link rel="alternate" type="text/html" href="https://wiki.hard-light.org/index.php?title=Tutorial_-_Bitwise_Operations&amp;diff=44178&amp;oldid=prev"/>
		<updated>2014-08-04T05:36:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Bitwise Basics: &lt;/span&gt;  Axem can&amp;#039;t math&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&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 05:36, 4 August 2014&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-l9&quot;&gt;Line 9:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 9:&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;Huh?!&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;Huh?!&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;In our traditional base-10 math, if we have the number &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;150&lt;/del&gt;, we could break it up into 100 + 50 + 2. We could then express each of those numbers as a number times a power of ten. So 152 = 100 + 50 + 2 = (1 x 10^2) + (5 x 10^1) + (0 x 10^0). To express that we can just go 1 5 0. Which is stupidly obvious.&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;In our traditional base-10 math, if we have the number &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;152&lt;/ins&gt;, we could break it up into 100 + 50 + 2. We could then express each of those numbers as a number times a power of ten. So 152 = 100 + 50 + 2 = (1 x 10^2) + (5 x 10^1) + (0 x 10^0). To express that we can just go 1 5 0. Which is stupidly obvious.&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;&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;What if we&amp;#039;re restricted to base 2 (aka binary, just a 1 or 0, like computers) and have the number 12? Powers of 2 are 1, 2, 4, 8, 16, 32, 64 … etc etc. So to get 12 out of that we could just go 8 + 4. So our base 2 number would look like (1x2^3) + (1x2^2) + (0x2^1) + (0x2^0). Or just 1 1 0 0. That 12 is actually being store as 1100 inside the computer program.&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;What if we&amp;#039;re restricted to base 2 (aka binary, just a 1 or 0, like computers) and have the number 12? Powers of 2 are 1, 2, 4, 8, 16, 32, 64 … etc etc. So to get 12 out of that we could just go 8 + 4. So our base 2 number would look like (1x2^3) + (1x2^2) + (0x2^1) + (0x2^0). Or just 1 1 0 0. That 12 is actually being store as 1100 inside the computer program.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Goober5000</name></author>
	</entry>
	<entry>
		<id>https://wiki.hard-light.org/index.php?title=Tutorial_-_Bitwise_Operations&amp;diff=44177&amp;oldid=prev</id>
		<title>Axem: Bitwise operations tutorial for FRED</title>
		<link rel="alternate" type="text/html" href="https://wiki.hard-light.org/index.php?title=Tutorial_-_Bitwise_Operations&amp;diff=44177&amp;oldid=prev"/>
		<updated>2014-08-03T14:34:31Z</updated>

		<summary type="html">&lt;p&gt;Bitwise operations tutorial for FRED&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Get wise with bitwise!&lt;br /&gt;
&lt;br /&gt;
If you have any sort of computer science background, the term bitwise should come second-nature to you. If you&amp;#039;re not, then here&amp;#039;s a quick rundown.&lt;br /&gt;
&lt;br /&gt;
==Bitwise Basics==&lt;br /&gt;
&lt;br /&gt;
Computer programs don&amp;#039;t store numbers as the numbers we know in base-10, they store them as bytes. What&amp;#039;s a byte? A byte is a bunch of 1s and 0s bunched together. The single element (the 1 or 0) is just called a bit. The computer program looks at the bits in the byte and reconstructs the number we&amp;#039;re looking for by using each bit&amp;#039;s place value as a power of two.&lt;br /&gt;
&lt;br /&gt;
Huh?!&lt;br /&gt;
&lt;br /&gt;
In our traditional base-10 math, if we have the number 150, we could break it up into 100 + 50 + 2. We could then express each of those numbers as a number times a power of ten. So 152 = 100 + 50 + 2 = (1 x 10^2) + (5 x 10^1) + (0 x 10^0). To express that we can just go 1 5 0. Which is stupidly obvious.&lt;br /&gt;
&lt;br /&gt;
What if we&amp;#039;re restricted to base 2 (aka binary, just a 1 or 0, like computers) and have the number 12? Powers of 2 are 1, 2, 4, 8, 16, 32, 64 … etc etc. So to get 12 out of that we could just go 8 + 4. So our base 2 number would look like (1x2^3) + (1x2^2) + (0x2^1) + (0x2^0). Or just 1 1 0 0. That 12 is actually being store as 1100 inside the computer program.&lt;br /&gt;
&lt;br /&gt;
==Using in FRED==&lt;br /&gt;
&lt;br /&gt;
Imagine we have a campaign going with 4 persistent ships. &lt;br /&gt;
&lt;br /&gt;
[[file:Bitwise1.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Our wonderful fleet.&lt;br /&gt;
&lt;br /&gt;
How could we easily keep track if they are alive or dead? (Let&amp;#039;s pretend that the health of each ship doesn&amp;#039;t matter, just if they&amp;#039;re alive or dead.) is-previous-event-false ShipAWasDestroyed? Sure, but if our campaign is going to be long, you&amp;#039;re going to be checking a lot of previous events. Put its status in a variable? This is good, but updating 4 variables throughout a campaign? What a… pain.&lt;br /&gt;
&lt;br /&gt;
Hey, look at that bitwise example above. If our variable&amp;#039;s bits corresponded to the status of our ships, that could work. So 1 1 1 1 would be all four ships are alive. 1 0 1 0 would be 2 ships alive, 2 dead, 0 1 0 1 would be the other 2 ships alive and the other 2 dead. Let&amp;#039;s see how we could accomplish this.&lt;br /&gt;
&lt;br /&gt;
When we make a new integer variable in FRED, a common default value is 0, but inside FRED there&amp;#039;s quite a few more zeroes. An integer variable inside FRED is 4 bytes, or 32 bits. This means FRED really is storing 0000 0000  0000 0000  0000 0000  0000 0000 for the default value of 0 (spaces added to help with readability). So we could theoretically store 32 ships with this system, but we&amp;#039;ll just stick to 4 for the time being.&lt;br /&gt;
&lt;br /&gt;
So when we store our ship&amp;#039;s status, we want 1 1 1 1 since they are all alive. We would NOT just type in 1111, because in binary that is actually 0100 0101 0111. Not quite what we&amp;#039;re looking for. Constructing the number in binary and be tricky for people unfamiliar with binary (FYI its 15). So maybe instead of making each bit &amp;quot;is this ship alive?&amp;quot; we could just think of each bit as &amp;quot;is this ship dead?&amp;quot; That way we can just keep our initial value at zero.&lt;br /&gt;
&lt;br /&gt;
Now how do we modify our variable properly if a ship dies? This nifty set-bit sexp. Now the set-bit operator only returns the value of a variable after a specific bit is set. Set-bit by itself doesn&amp;#039;t modify the variable, we still need to use the modify-variable sexp first. But it&amp;#039;s still simple enough to use.&lt;br /&gt;
&lt;br /&gt;
[[file:Bitwise2.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Modify FleetStatus to be FleetStatus with Bit Index 0, 1, 2 or 3 set&amp;quot; (Quick note, computers love to start counting at 0, so index 0 is technically the first bit)&lt;br /&gt;
&lt;br /&gt;
Then at the beginning of each mission (or the arrival cue) we just check a bit&amp;#039;s status with is-bit-set to see if it should arrive.&lt;br /&gt;
&lt;br /&gt;
[[file:Bitwise3.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Yes, using bit-wise operations with integer variables allows you to cram 32 true/false variables into that single variable.&lt;br /&gt;
&lt;br /&gt;
To get into some real advanced things, you can also play with bitwise AND, OR and XOR operators. Check out [http://en.wikipedia.org/wiki/Bitwise_operation this wikipedia article] for more great info on those. &lt;br /&gt;
&lt;br /&gt;
If you need more than true or false, you could do similar things with string-get/set-substring. It works similar to the bitwise operators, it only affects a desired section of the variable. For instance you could store things like morale levels for a squad of fighters, a rough health status for turrets, or responses when a player was asked a question. Things can get pretty complicated though, so take things nice and slow.&lt;br /&gt;
&lt;br /&gt;
[[Category:FRED Examples]][[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Axem</name></author>
	</entry>
</feed>