<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.explainxkcd.com/wiki/index.php?action=history&amp;feed=atom&amp;title=3062%3A_Off_By_One</id>
		<title>3062: Off By One - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.explainxkcd.com/wiki/index.php?action=history&amp;feed=atom&amp;title=3062%3A_Off_By_One"/>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;action=history"/>
		<updated>2026-05-23T17:01:43Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=379559&amp;oldid=prev</id>
		<title>FaviFake: /* Explanation */</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=379559&amp;oldid=prev"/>
				<updated>2025-06-16T14:30:47Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Explanation&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 14:30, 16 June 2025&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-l26&quot; &gt;Line 26:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 26:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' complementary invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of this per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' complementary invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of this per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors. The title text can be used to infer that the 40-to-50 range is inclusive on both ends, despite the word &amp;quot;between&amp;quot; also possibly implying an exclusive range, in different contexts.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;The title text can be used to infer that the 40-to-50 range is inclusive on both ends, despite the word &amp;quot;between&amp;quot; also possibly implying an exclusive range, in different contexts.&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Transcript==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Transcript==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>FaviFake</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=379558&amp;oldid=prev</id>
		<title>FaviFake: /* Explanation */ complete</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=379558&amp;oldid=prev"/>
				<updated>2025-06-16T14:30:32Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Explanation: &lt;/span&gt; complete&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 14:30, 16 June 2025&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-l10&quot; &gt;Line 10:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 10:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Explanation==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Explanation==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;{{&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;incomplete&lt;/del&gt;|&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;The explanation &lt;/del&gt;is too &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;technical and hard &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;understand for normal readers.&lt;/del&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;In computer programming and computer science, an &lt;/ins&gt;{{&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;w&lt;/ins&gt;|&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;off-by-one error}} &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a very common human mistake made by an engineer who instructed the computer to process one &lt;/ins&gt;too &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;terminate a {{w|Loop (programming)|loop&lt;/ins&gt;}} &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;or, alternately, ≥ mixed up with &amp;gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;: Imagine a literal interpretation of &amp;quot;When you get to the last task, you are done.&amp;quot; (which means you don't need to complete the final task) as opposed to &amp;quot;When you have completed the last task, you are done&amp;quot;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;In computer programming and computer science, an {{w|off-by-one error}} is a very common human mistake made by an engineer who instructed the computer to process one too many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;* Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of {{w|Array (data type)|arrays}} in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. When using an {{w|Array (data structure)|array data structure}}, where elements are stored at equally spaced {{w|memory address}}es, zero-indexing lets you calculate the address of the &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;th element more easily: address(&amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;) = address(&amp;lt;var&amp;gt;array&amp;lt;/var&amp;gt;) + &amp;lt;var&amp;gt;spacing&amp;lt;/var&amp;gt; &amp;amp;times; &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;. However, not all programming languages do this.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;*Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed to terminate a {{w|Loop (programming)|loop}}, or vice versa (or, alternately, ≥ mixed up with &amp;gt;) (Imagine a literal interpretation of &amp;quot;when you get to the last task you are done&amp;quot; as opposed to &amp;quot;when you have completed the last task you are done&amp;quot;.)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;*Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of {{w|Array (data type)|arrays}} in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. When using an {{w|Array (data structure)|array data structure}}, where elements are stored at equally spaced {{w|memory address}}es, zero-indexing lets you calculate the address of the &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;th element more easily: address(&amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;) = address(&amp;lt;var&amp;gt;array&amp;lt;/var&amp;gt;) + &amp;lt;var&amp;gt;spacing&amp;lt;/var&amp;gt; &amp;amp;times; &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;. However, not all programming languages do this. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;(More tangibly, imagine &lt;/del&gt;a set of detailed instructions for washing dishes using a loop that starts with &amp;quot;put away any dish in your hands and pick up the next dish&amp;quot;.&amp;#160; If you read the instructions with a dish already in your hand, that first dish will never get washed.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;: Imagine &lt;/ins&gt;a set of detailed instructions for washing dishes using a loop that starts with &amp;quot;put away any dish in your hands and pick up the next dish&amp;quot;.&amp;#160; If you read the instructions with a dish already in your hand, that first dish will never get washed.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; (A more concrete explanation&lt;/del&gt;: &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;imagine that &lt;/del&gt;you are building a fence, with 1 meter panels between fenceposts. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;To build a 10 meter fence you need 11 fenceposts, as you need an &amp;quot;extra&amp;quot; one at the end. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;If you assume that a 10 meter fence needs 10 fenceposts, one per panel, you have a fencepost error &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;-- &lt;/del&gt;the correct algorithm is that you need one fencepost plus one per panel.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;* {{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;: &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Imagine &lt;/ins&gt;you are building a fence, with 1&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;-&lt;/ins&gt;meter panels between fenceposts. To build a 10&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;-&lt;/ins&gt;meter fence you need 11 fenceposts, as you need an &amp;quot;extra&amp;quot; one at the end. If you assume that a 10&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;-&lt;/ins&gt;meter fence needs 10 fenceposts, one per panel, you have a fencepost error &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;— &lt;/ins&gt;the correct algorithm is that you need one fencepost plus one per panel.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' complementary invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of this per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' complementary invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of this per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>FaviFake</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=370394&amp;oldid=prev</id>
		<title>FaviFake: /* Explanation */</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=370394&amp;oldid=prev"/>
				<updated>2025-03-26T15:57:16Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Explanation&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 15:57, 26 March 2025&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-l10&quot; &gt;Line 10:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 10:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Explanation==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Explanation==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;{{incomplete|The explanation is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;currently &lt;/del&gt;too hard to understand for &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;non-technical &lt;/del&gt;readers.}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;{{incomplete|The explanation is too &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;technical and &lt;/ins&gt;hard to understand for &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;normal &lt;/ins&gt;readers.}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In computer programming and computer science, an {{w|off-by-one error}} is a very common human mistake made by an engineer who instructed the computer to process one too many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In computer programming and computer science, an {{w|off-by-one error}} is a very common human mistake made by an engineer who instructed the computer to process one too many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>FaviFake</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=370351&amp;oldid=prev</id>
		<title>Alexis J. Morganza: /* Explanation */ add tangible explanations of three error classes; also fixed typo &quot;fhis&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=370351&amp;oldid=prev"/>
				<updated>2025-03-25T21:39:53Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Explanation: &lt;/span&gt; add tangible explanations of three error classes; also fixed typo &amp;quot;fhis&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 21:39, 25 March 2025&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-l12&quot; &gt;Line 12:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 12:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{incomplete|The explanation is currently too hard to understand for non-technical readers.}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{incomplete|The explanation is currently too hard to understand for non-technical readers.}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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 computer programming and computer science, an {{w|off-by-one error}} is a very common human mistake &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;left &lt;/del&gt;by an engineer who instructed the computer to process one too many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 computer programming and computer science, an {{w|off-by-one error}} is a very common human mistake &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;made &lt;/ins&gt;by an engineer who instructed the computer to process one too many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;*Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed to terminate a {{w|Loop (programming)|loop}}, or vice versa (or, alternately, ≥ mixed up with &amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;*Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed to terminate a {{w|Loop (programming)|loop}}, or vice versa (or, alternately, ≥ mixed up with &amp;gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;) (Imagine a literal interpretation of &amp;quot;when you get to the last task you are done&amp;quot; as opposed to &amp;quot;when you have completed the last task you are done&amp;quot;.&lt;/ins&gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;*Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of {{w|Array (data type)|arrays}} in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. When using an {{w|Array (data structure)|array data structure}}, where elements are stored at equally spaced {{w|memory address}}es, zero-indexing lets you calculate the address of the &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;th element more easily: address(&amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;) = address(&amp;lt;var&amp;gt;array&amp;lt;/var&amp;gt;) + &amp;lt;var&amp;gt;spacing&amp;lt;/var&amp;gt; &amp;amp;times; &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;. However, not all programming languages do this.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;*Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of {{w|Array (data type)|arrays}} in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. When using an {{w|Array (data structure)|array data structure}}, where elements are stored at equally spaced {{w|memory address}}es, zero-indexing lets you calculate the address of the &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;th element more easily: address(&amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;) = address(&amp;lt;var&amp;gt;array&amp;lt;/var&amp;gt;) + &amp;lt;var&amp;gt;spacing&amp;lt;/var&amp;gt; &amp;amp;times; &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;. However, not all programming languages do this. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(More tangibly, imagine a set of detailed instructions for washing dishes using a loop that starts with &amp;quot;put away any dish in your hands and pick up the next dish&amp;quot;.&amp;#160; If you read the instructions with a dish already in your hand, that first dish will never get washed.)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; (A more concrete explanation: imagine that you are building a fence, with 1 meter panels between fenceposts.&amp;#160; To build a 10 meter fence you need 11 fenceposts, as you need an &amp;quot;extra&amp;quot; one at the end.&amp;#160; If you assume that a 10 meter fence needs 10 fenceposts, one per panel, you have a fencepost error -- the correct algorithm is that you need one fencepost plus one per panel.)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' complementary invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;fhis &lt;/del&gt;per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' complementary invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;this &lt;/ins&gt;per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Alexis J. Morganza</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=369453&amp;oldid=prev</id>
		<title>172.70.58.5: Fixed use of &quot;complimentary&quot; for &quot;complementary&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=369453&amp;oldid=prev"/>
				<updated>2025-03-19T12:49:07Z</updated>
		
		<summary type="html">&lt;p&gt;Fixed use of &amp;quot;complimentary&amp;quot; for &amp;quot;complementary&amp;quot;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 12:49, 19 March 2025&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-l17&quot; &gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;complimentary &lt;/del&gt;invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of fhis per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;complementary &lt;/ins&gt;invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of fhis per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>172.70.58.5</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368867&amp;oldid=prev</id>
		<title>172.70.163.34: /* Explanation */</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368867&amp;oldid=prev"/>
				<updated>2025-03-14T00:38:29Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Explanation&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 00:38, 14 March 2025&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-l17&quot; &gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;identical &lt;/del&gt;invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of fhis per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is never off by one (only a further, ''nearly'' &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;complimentary &lt;/ins&gt;invocation of the ±[40..50] error will produce such a seemingly simple error). This severe change would introduce immediate failures in almost every program that does not have efficient error-catching and fault-tolerance. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to account for the possibilities of all of their values being at least 50 off from the intended value in every elemental variable read/write (possibly multiple cases of fhis per statement, or line). For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>172.70.163.34</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368864&amp;oldid=prev</id>
		<title>172.69.195.4: /* Explanation */</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368864&amp;oldid=prev"/>
				<updated>2025-03-13T23:51:13Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Explanation&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 23:51, 13 March 2025&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-l17&quot; &gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;rarely &lt;/del&gt;off by one. This severe change would introduce immediate failures in almost every program. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;design &lt;/del&gt;for all of their values being &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;up to &lt;/del&gt;50 off from &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;correct &lt;/del&gt;in every statement or line. For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;never &lt;/ins&gt;off by one &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(only a further, ''nearly'' identical invocation of the ±[40..50] error will produce such a seemingly simple error)&lt;/ins&gt;. This severe change would introduce immediate failures in almost every program &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;that does not have efficient error-catching and fault-tolerance&lt;/ins&gt;. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;account &lt;/ins&gt;for &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the possibilities of &lt;/ins&gt;all of their values being &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;at least &lt;/ins&gt;50 off from &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the intended value &lt;/ins&gt;in every &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;elemental variable read/write (possibly multiple cases of fhis per &lt;/ins&gt;statement&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/ins&gt;or line&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;)&lt;/ins&gt;. For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The title text states the obvious; by changing every number by 40 to 50, any number will be 40 to 50 off. This will compound further as the change can happen many times on a single line, as well as further by existing unforced off-by-one errors (or itself being left ill-defined or misunderstood, depending on whether &amp;quot;between&amp;quot; here is being understood as inclusive or exclusive) leading to potential off-by-39-to-51 errors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;The title text can be used to infer that the 40-to-50 range is inclusive on both ends, despite the word &amp;quot;between&amp;quot; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;often &lt;/del&gt;implying an exclusive range.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The title text can be used to infer that the 40-to-50 range is inclusive on both ends, despite the word &amp;quot;between&amp;quot; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;also possibly &lt;/ins&gt;implying an exclusive range&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, in different contexts&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Transcript==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Transcript==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>172.69.195.4</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368862&amp;oldid=prev</id>
		<title>AgentMuffin at 23:15, 13 March 2025</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368862&amp;oldid=prev"/>
				<updated>2025-03-13T23:15:50Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 23:15, 13 March 2025&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-l14&quot; &gt;Line 14:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In computer programming and computer science, an {{w|off-by-one error}} is a very common human mistake left by an engineer who instructed the computer to process one too many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In computer programming and computer science, an {{w|off-by-one error}} is a very common human mistake left by an engineer who instructed the computer to process one too many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed to terminate a {{w|Loop (programming)|loop}}, or vice versa (or, alternately, ≥ mixed up with &amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed to terminate a {{w|Loop (programming)|loop}}, or vice versa (or, alternately, ≥ mixed up with &amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;*Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of arrays in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. (However, not all programming languages do this.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;*Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{w|Array (data type)|&lt;/ins&gt;arrays&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;}} &lt;/ins&gt;in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;When using an {{w|Array (data structure)|array data structure}}, where elements are stored at equally spaced {{w|memory address}}es, zero-indexing lets you calculate the address of the &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;th element more easily: address(&amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;) = address&lt;/ins&gt;(&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;var&amp;gt;array&amp;lt;/var&amp;gt;) + &amp;lt;var&amp;gt;spacing&amp;lt;/var&amp;gt; &amp;amp;times; &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;. &lt;/ins&gt;However, not all programming languages do this.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}. This is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}. This is one more than the difference, and one more than the length usually used in software engineering, so the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>AgentMuffin</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368861&amp;oldid=prev</id>
		<title>AgentMuffin at 23:06, 13 March 2025</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368861&amp;oldid=prev"/>
				<updated>2025-03-13T23:06:40Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 23:06, 13 March 2025&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-l15&quot; &gt;Line 15:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 15:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed to terminate a {{w|Loop (programming)|loop}}, or vice versa (or, alternately, ≥ mixed up with &amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed to terminate a {{w|Loop (programming)|loop}}, or vice versa (or, alternately, ≥ mixed up with &amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of arrays in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. (However, not all programming languages do this.)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of arrays in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. (However, not all programming languages do this.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, which &lt;/del&gt;is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, which &lt;/del&gt;is one more than the difference, and one more than the length usually used in software engineering&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;. So &lt;/del&gt;the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;*{{w|Fencepost error}}s (which some consider to be synonymous with off-by-one errors). These are often related to the norm, in programming language loop constructs, to require inclusivity on the lower side of the range but exclusivity on the upper side [&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;). Consider the length of a range, such as the whole numbers from 4 to 6. If this is considered inclusive on one side and exclusive on the other, then the correct length is 2, to count the set {4, 5}&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. This &lt;/ins&gt;is easily obtained via the subtraction &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3, to count the set {4, 5, 6}&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. This &lt;/ins&gt;is one more than the difference, and one more than the length usually used in software engineering&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, so &lt;/ins&gt;the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is rarely off by one. This severe change would introduce immediate failures in almost every program. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to design for all of their values being up to 50 off from correct in every statement or line. For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is rarely off by one. This severe change would introduce immediate failures in almost every program. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to design for all of their values being up to 50 off from correct in every statement or line. For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>AgentMuffin</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368860&amp;oldid=prev</id>
		<title>AgentMuffin at 23:05, 13 March 2025</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=3062:_Off_By_One&amp;diff=368860&amp;oldid=prev"/>
				<updated>2025-03-13T23:05:31Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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 style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 23:05, 13 March 2025&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-l13&quot; &gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In computer programming and computer science, an {{w|off-by-one error}} is a very common human mistake left by an engineer who instructed the computer to process one too many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In computer programming and computer science, an {{w|off-by-one error}} is a very common human mistake left by an engineer who instructed the computer to process one too many or one too few items than are actually present. This can arise from a number of sources, including:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;*Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed to terminate a loop, or vice versa (or, alternately, ≥ mixed up with &amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;*Mistakenly using a ≤ (less than or equals) comparison where a &amp;lt; (less than) comparison was needed to terminate a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{w|Loop (programming)|&lt;/ins&gt;loop&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;}}&lt;/ins&gt;, or vice versa (or, alternately, ≥ mixed up with &amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of arrays in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. (However, not all programming languages do this.)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Confusion between {{w|Zero-based numbering|zero-}} and one-based indexing of arrays in code, either by convention or by definition in the code. Often, when numbering (indexing) elements in programming, counting starts from 0, so the initial element is not the &amp;quot;first&amp;quot; but actually the &amp;quot;zeroth&amp;quot;. (However, not all programming languages do this.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;*{{w|Fencepost error}}s&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, a term considered by &lt;/del&gt;some to be synonymous with off-by-one errors&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;often related to the norm in programming language loop constructs to require inclusivity on the lower side of the range but exclusivity on the upper side. Consider the length of a range, such as the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;values &lt;/del&gt;4 to 6 &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;mdash; if &lt;/del&gt;this is considered inclusive on one side and exclusive on the other, then the correct length is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;&lt;/del&gt;2&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot; &lt;/del&gt;which is easily obtained via subtraction. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;&lt;/del&gt;3&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot; (&lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;values &lt;/del&gt;4, 5, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp; &lt;/del&gt;6&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;)&lt;/del&gt;, which is one more than the difference, and one more than the length usually used in software engineering.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;*{{w|Fencepost error}}s &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(which &lt;/ins&gt;some &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;consider &lt;/ins&gt;to be synonymous with off-by-one errors&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;). These are &lt;/ins&gt;often related to the norm&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/ins&gt;in programming language loop constructs&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/ins&gt;to require inclusivity on the lower side of the range but exclusivity on the upper side &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; ≤ &amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt; &amp;lt; &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt;)&lt;/ins&gt;. Consider the length of a range, such as the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;whole numbers from &lt;/ins&gt;4 to 6&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. If &lt;/ins&gt;this is considered inclusive on one side and exclusive on the other, then the correct length is 2&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, to count the set {4, 5}, &lt;/ins&gt;which is easily obtained via &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the &lt;/ins&gt;subtraction &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt;&lt;/ins&gt;. However, if the range is considered inclusive on both sides, as when placing fenceposts to hold a length of fence, then the correct length is 3&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, to count &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;set {&lt;/ins&gt;4, 5, 6&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;}&lt;/ins&gt;, which is one more than the difference, and one more than the length usually used in software engineering&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. So the formula for this case is actually &amp;lt;var&amp;gt;max&amp;lt;/var&amp;gt; &amp;amp;minus; &amp;lt;var&amp;gt;min&amp;lt;/var&amp;gt; + 1&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is rarely off by one. This severe change would introduce immediate failures in almost every program. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to design for all of their values being up to 50 off from correct in every statement or line. For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Cueball]] has attempted to combat off-by-one errors in his new programming language by introducing off-by-40-to-50 errors, which will indeed ensure that a simple reference to a value is rarely off by one. This severe change would introduce immediate failures in almost every program. A programmer attempting to correct such failures would end up completely removing direct comparison with the end value of a range, the usual cause of off-by-one errors, but would have to design for all of their values being up to 50 off from correct in every statement or line. For example, a normal loop can miss many elements (and possibly revisit others more than once, and/or out of order), not just possibly omit or over-extend one of the endpoints.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>AgentMuffin</name></author>	</entry>

	</feed>