From Clomosy Docs

No edit summary
No edit summary
Line 7: Line 7:
<b>Example</b><br>
<b>Example</b><br>
In the example, it will return the remainder of dividing 20 by 12. So as a result you will see the value 8 on the screen.<br>
In the example, it will return the remainder of dividing 20 by 12. So as a result you will see the value 8 on the screen.<br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
var
var
Line 19: Line 19:


}
}
</pre>
<b>Base Syntax</b><br>
<pre>
var
  dividingNumber,divisor,remainder : Integer;
begin
  dividingNumber := 20;
  divisor := 12;
  remainder := dividingNumber Mod divisor;
  ShowMessage(IntToStr(dividingNumber)+' Mod '+IntToStr(divisor)+' :'+IntToStr(remainder));
end;
</pre>
</pre>



Revision as of 12:17, 13 November 2024

The mod keyword returns the remainder of the division of two numbers. The integer result of the division is ignored.

Example
In the example, it will return the remainder of dividing 20 by 12. So as a result you will see the value 8 on the screen.

var
  dividingNumber,divisor,remainder : Integer;
 
{
  dividingNumber = 20;
  divisor = 12;
  remainder = dividingNumber Mod divisor;
  ShowMessage(IntToStr(dividingNumber)+' Mod '+IntToStr(divisor)+' :'+IntToStr(remainder));

}

Output:

See Also