MOD/de
From MCS Wiki AVR
< MOD(Difference between revisions)
(Created page with "= <span class="f_Header">Action</span> = Calculates the remainder of a division. <span style="font-family: Arial;"> </span> <span style="font-family: Arial;"> </s...") |
(→Example) |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | = <span class="f_Header">Funktion</span> = | |
| − | + | Berechnet den Rest einer Division. | |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
| Line 15: | Line 15: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
| − | = <span class="f_Header"> | + | = <span class="f_Header">Anmerkungen</span> = |
<div style="padding: 0px; margin: 0px 0px 0px 4px;"> | <div style="padding: 0px; margin: 0px 0px 0px 4px;"> | ||
{| width="597" cellspacing="0" cellpadding="1" border="1" style="border: 1px solid rgb(0, 0, 0); border-spacing: 0px;" | {| width="597" cellspacing="0" cellpadding="1" border="1" style="border: 1px solid rgb(0, 0, 0); border-spacing: 0px;" | ||
| Line 23: | Line 23: | ||
| valign="top" width="100%" style="width: 532px; border: 1px solid rgb(0, 0, 0);" | | | valign="top" width="100%" style="width: 532px; border: 1px solid rgb(0, 0, 0);" | | ||
| − | Variable | + | Variable, der Ergebnis zugewiesen wird. |
|- style="vertical-align: top;" | |- style="vertical-align: top;" | ||
| Line 30: | Line 30: | ||
| valign="top" width="100%" style="width: 532px; border: 1px solid rgb(0, 0, 0);" | | | valign="top" width="100%" style="width: 532px; border: 1px solid rgb(0, 0, 0);" | | ||
| − | + | Numerische Variable von der der Modulo berechnet werden soll | |
|- style="vertical-align: top;" | |- style="vertical-align: top;" | ||
| Line 37: | Line 37: | ||
| valign="top" width="100%" style="width: 532px; border: 1px solid rgb(0, 0, 0);" | | | valign="top" width="100%" style="width: 532px; border: 1px solid rgb(0, 0, 0);" | | ||
| − | + | Teiler | |
|} | |} | ||
| Line 43: | Line 43: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
| − | + | Die MOD-Operation ist ähnlich wie die Division (/). Während allerdings die Division das Divisionsergebnis zurückgibt gibt MOD den Rest der Division zurück. | |
| | ||
| − | + | Zum Beispiel: 21 MOD 3 ergibt 0 weil 7x3=21. Es gibt keinen Rest. | |
| − | + | Aber 22 MOD 3 ergibt 1 weil 22-(7x3)=1 | |
| | ||
| − | In BASCOM, | + | In BASCOM bestimmt die Variable, der etwas zugewiesen wird die Berechnungsart. Wenn man zwei Word-Zahlen für MOD hat dann muss man auch einer Word-Variablen zuweisen. |
| − | + | Wenn einer Byte-Variablen zugewiesen wird dann wird Byte-Arithmetik benutzt. | |
| | ||
| Line 63: | Line 63: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
| − | = <span class="f_Header"> | + | = <span class="f_Header">Siehe auch</span> = |
[[Language Fundamentals|Language Fundamentals]] | [[Language Fundamentals|Language Fundamentals]] | ||
| Line 71: | Line 71: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
| − | = <span class="f_Header"> | + | = <span class="f_Header">Beispiel</span> = |
<br/><source lang="bascomavr"> | <br/><source lang="bascomavr"> | ||
| Line 77: | Line 77: | ||
For L = 1 To 1000 | For L = 1 To 1000 | ||
L2 = L Mod 100 | L2 = L Mod 100 | ||
| − | If L2 = 0 Then ' | + | If L2 = 0 Then ' Vielfaches von 100 |
Print L | Print L | ||
End If | End If | ||
Latest revision as of 01:49, 10 March 2013
Contents |
Funktion
Berechnet den Rest einer Division.
Syntax
var1 = var2 MOD var3
Anmerkungen
|
var1 |
Variable, der Ergebnis zugewiesen wird. |
|
var2 |
Numerische Variable von der der Modulo berechnet werden soll |
|
var3 |
Teiler |
Die MOD-Operation ist ähnlich wie die Division (/). Während allerdings die Division das Divisionsergebnis zurückgibt gibt MOD den Rest der Division zurück.
Zum Beispiel: 21 MOD 3 ergibt 0 weil 7x3=21. Es gibt keinen Rest.
Aber 22 MOD 3 ergibt 1 weil 22-(7x3)=1
In BASCOM bestimmt die Variable, der etwas zugewiesen wird die Berechnungsart. Wenn man zwei Word-Zahlen für MOD hat dann muss man auch einer Word-Variablen zuweisen.
Wenn einer Byte-Variablen zugewiesen wird dann wird Byte-Arithmetik benutzt.
Siehe auch
Beispiel
Dim L As Long , L2 As Long For L = 1 To 1000 L2 = L Mod 100 If L2 = 0 Then ' Vielfaches von 100 Print L End If Next
| Languages | English • Deutsch |
|---|