<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://bloggingadeadhorse.com/arduboyWiki/index.php?action=history&amp;feed=atom&amp;title=Modulus_Function</id>
	<title>Modulus Function - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://bloggingadeadhorse.com/arduboyWiki/index.php?action=history&amp;feed=atom&amp;title=Modulus_Function"/>
	<link rel="alternate" type="text/html" href="https://bloggingadeadhorse.com/arduboyWiki/index.php?title=Modulus_Function&amp;action=history"/>
	<updated>2026-10-23T00:15:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://bloggingadeadhorse.com/arduboyWiki/index.php?title=Modulus_Function&amp;diff=612&amp;oldid=prev</id>
		<title>Filmote at 01:30, 17 August 2024</title>
		<link rel="alternate" type="text/html" href="https://bloggingadeadhorse.com/arduboyWiki/index.php?title=Modulus_Function&amp;diff=612&amp;oldid=prev"/>
		<updated>2024-08-17T01:30:05Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:30, 17 August 2024&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-l18&quot;&gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Consider the function below. It tests to see if a number is odd by checking the modulus is one. Of course, this will fail if the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;&lt;/del&gt;numberToTest&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039; &lt;/del&gt;is negative.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Consider the function below. It tests to see if a number is odd by checking the modulus is one. Of course, this will fail if the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;numberToTest&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;is negative.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Filmote</name></author>
	</entry>
	<entry>
		<id>https://bloggingadeadhorse.com/arduboyWiki/index.php?title=Modulus_Function&amp;diff=611&amp;oldid=prev</id>
		<title>Filmote: Created page with &quot;A modulus (modulo, mod) is simply the remainder when dividing one number by another. When we divide 7 by 2 the result is 3 with 1 remainder.  In C / C++ the operand &lt;code&gt;%&lt;/code&gt; returns the modulus between two numbers, for example:  &lt;pre&gt; Serial.println(7 % 2);          &gt;&gt;   Outputs ‘1’. &lt;/pre&gt;   One ‘gotcha’ with the modulus operation is that it returns the modulus using the same sign as the dividend.  The sign of the divisor is irrelevant. The examples below...&quot;</title>
		<link rel="alternate" type="text/html" href="https://bloggingadeadhorse.com/arduboyWiki/index.php?title=Modulus_Function&amp;diff=611&amp;oldid=prev"/>
		<updated>2024-08-17T01:29:37Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;A modulus (modulo, mod) is simply the remainder when dividing one number by another. When we divide 7 by 2 the result is 3 with 1 remainder.  In C / C++ the operand &amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt; returns the modulus between two numbers, for example:  &amp;lt;pre&amp;gt; Serial.println(7 % 2);          &amp;gt;&amp;gt;   Outputs ‘1’. &amp;lt;/pre&amp;gt;   One ‘gotcha’ with the modulus operation is that it returns the modulus using the same sign as the dividend.  The sign of the divisor is irrelevant. The examples below...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A modulus (modulo, mod) is simply the remainder when dividing one number by another. When we divide 7 by 2 the result is 3 with 1 remainder.&lt;br /&gt;
&lt;br /&gt;
In C / C++ the operand &amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt; returns the modulus between two numbers, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Serial.println(7 % 2);          &amp;gt;&amp;gt;   Outputs ‘1’.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
One ‘gotcha’ with the modulus operation is that it returns the modulus using the same sign as the dividend.&lt;br /&gt;
&lt;br /&gt;
The sign of the divisor is irrelevant. The examples below shows this in action:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Serial.println(7 % 2);          &amp;gt;&amp;gt;   Outputs ‘1’.&lt;br /&gt;
Serial.println(-7 % 2);         &amp;gt;&amp;gt;   Outputs ‘-1’.&lt;br /&gt;
Serial.println(7 % -2);         &amp;gt;&amp;gt;   Outputs ‘1’.&lt;br /&gt;
Serial.println(-7 % -2);        &amp;gt;&amp;gt;   Outputs ‘-1’.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Consider the function below. It tests to see if a number is odd by checking the modulus is one. Of course, this will fail if the &amp;#039;&amp;#039;&amp;#039;numberToTest&amp;#039;&amp;#039;&amp;#039; is negative.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bool isAnOddNumber(int numberToTest) {&lt;br /&gt;
  return numberToTest % 2 == 1;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changing the function to test for a non-zero number - a one or a negative one – accounts for both positive or negative inputs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bool isAnOddNumber(int numberToTest) {&lt;br /&gt;
  return numberToTest % 2 != 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Filmote</name></author>
	</entry>
</feed>