Language Fundamentals/de

From MCS Wiki AVR
< Language Fundamentals(Difference between revisions)
Jump to: navigation, search
 
(97 intermediate revisions by one user not shown)
Line 42: Line 42:
  
 
= <span class="f_Header">Zeichensatz</span> =
 
= <span class="f_Header">Zeichensatz</span> =
 
<span style="font-family: Arial;">&nbsp;</span>
 
 
The BASCOM BASIC character set consists of alphabetic characters, numeric characters, and special characters.
 
 
The alphabetic characters in BASCOM are the uppercase letters (A-Z) and lowercase letters (a-z) of the alphabet.
 
 
<span style="font-family: Arial;">&nbsp;</span>
 
 
  
  
Line 74: Line 65:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Terminates input of a line
+
Abschluss einer Engabezeile
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 81: Line 72:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Blank ( or space)
+
Leerzeichen ( oder Space)
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 88: Line 79:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Single quotation mark (apostrophe)
+
einfaches Anführungszeichen (Apostroph)
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
| valign="top" width="23%" style="width: 105px; border: 1px solid rgb(0, 0, 0);" |  
+
| valign="top" width="23%" style="width: 105px; border: 1px solid rgb(0, 0, 0);" | *
*
+
 
+
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Asterisks (multiplication symbol)
+
Stern (Multiplikation Symbol)
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 102: Line 91:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Plus sign
+
Plus Zeichen
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 109: Line 98:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Comma
+
Komma
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 116: Line 105:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Minus sign
+
Minus Zeichen
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 123: Line 112:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Period (decimal point)
+
Punkt (Dezimalpunkt)
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 130: Line 119:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Slash (division symbol) will be handled as \
+
Schrägstrich (Slash) (Division Symbol) wird wie \ behandelt
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
| valign="top" width="23%" style="width: 105px; border: 1px solid rgb(0, 0, 0);" |  
+
| valign="top" width="23%" style="width: 105px; border: 1px solid rgb(0, 0, 0);" | &nbsp;:
:
+
 
+
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Colon
+
Doppelpunkt
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 144: Line 131:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Double quotation mark
+
doppelte Anführungszeichen
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
| valign="top" width="23%" style="width: 105px; border: 1px solid rgb(0, 0, 0);" |  
+
| valign="top" width="23%" style="width: 105px; border: 1px solid rgb(0, 0, 0);" | &nbsp;;
;
+
 
+
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Semicolon
+
Semikolon
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 158: Line 143:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Less than
+
kleiner als
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 165: Line 150:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Equal sign (assignment symbol or relational operator)
+
Gleichheitszeichen (Zuweisungssymbol or relationaler Operator)
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 172: Line 157:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Greater than
+
größer als
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 179: Line 164:
  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 358px; border: 1px solid rgb(0, 0, 0);" |  
Backslash (integer/word division symbol)
+
Schrägstrich rückwärts (Backslash) (Division Symbol)
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 196: Line 181:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">The BASCOM program line</span> =
+
= <span class="f_Header">Die BASCOM Programmzeile</span> =
  
BASCOM program lines have the following syntax:
+
BASCOM Programmzeilen haben folgende Syntax:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 204: Line 189:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
&#x5B;&#x5B;line-identifier&#x5D;&#x5D; &#x5B;&#x5B;statement&#x5D;&#x5D; &#x5B;&#x5B;:statement&#x5D;&#x5D; ... &#x5B;&#x5B;comment&#x5D;&#x5D;
+
&#x5B;&#x5B;Line-identifier&#x5D;&#x5D; &#x5B;&#x5B;Statement&#x5D;&#x5D; &#x5B;&#x5B;:Statement&#x5D;&#x5D; ... &#x5B;&#x5B;Comment&#x5D;&#x5D;
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 210: Line 195:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
<span style="font-family: Arial;">&nbsp;</span>
+
= <span class="f_Header">Sprungmarken (Label)</span> =
 
+
= <span class="f_Header">Using Line Identifiers</span> =
+
  
BASCOM support one type of line-identifier; alphanumeric line labels:
+
BASCOM unterstützt alphanumerische Sprungmarken (Label).
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 220: Line 203:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
An alphabetic line label may be any combination of from 1 to 32 letters and digits, starting with a letter and ending with a colon.
+
Ein Label besteht aus 1 bis 32 Buchstaben oder Zahlen. Sie beginnen mit einem Buchstaben und enden mit einem Doppelpunkt.
  
BASCOM keywords are not permitted.
+
BASCOM Schlüsselwörter sind nicht erlaubt. (z.B. print:)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The following are valid alphanumeric line labels:
+
Beispiele zu gültigen Label:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 238: Line 221:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Case is not significant. The following line labels are equivalent:
+
Groß- Kleinschreibung wird nicht unterschieden. Folgende Beispiele zeigen unterschiedliche Schreibweisen, stehen aber für ein und dasselbe Label.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 252: Line 235:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Line labels may begin in any column, as long as they are the first characters other than blanks on the line.
+
Label können an einer beliebigen Stelle in einer Zeile beginnen, so lange sich links vom Label lediglich Leerzeichen befinden.
  
Blanks are not allowed between an alphabetic label and the colon following it.
+
Leerzeichen innerhalb des Label Namen und zwischen Label Name und dem abschließenden Doppelpunkt sind nicht erlaubt.
  
A line can have only one label. When there is a label on the line, no other identifiers may be used on the same line. So the label is the sole identifier on a line.
+
In einer Zeile darf sich nur ein Label befinden. In einer Zeile mit einem Label darf sich nur dieses Label befinden, also keine weiteren Anweisungen oder Instruktionen oder Ausdrücke. Ein Label ist der einzige Ausdruck in einer Zeile. (z.B. NICHT Label: print hier muss die Print Anweisung in der folgenden Zeile stehen)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 262: Line 245:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">BASCOM Statements</span> =
+
= <span class="f_Header">BASCOM Anweisungen (Befehle)</span> =
  
A BASCOM statement is either "executable" or " non-executable".
+
Eine BASCOM Anweisung ist entweder "ausführbar" oder "nicht ausführbar".
  
An executable statement advances the flow of a programs logic by telling the program what to do next.
+
Eine ausführbare Anweisung (Befehl) führt Schritte in der Programmlogik aus. Ein Beispiel eines ausführbare Befehl ist "Print". Hier wird der Befehl zur Ausgabe von Daten gegeben.
  
Non executable statement perform tasks such as allocating storage for variables, declaring and defining variable types.
+
Nicht ausführbare Anweisungen dienen z.B. der Speicherzuweisung, Deklaration oder Definition des Types von Variablen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The following BASCOM statements are examples of non-executable statements:
+
Im folgenden Beispiele für "nicht ausführbare Anweisungen"
 
<div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
<div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
{| border="0" cellpadding="0" cellspacing="0"
 
{| border="0" cellpadding="0" cellspacing="0"
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| REM or (starts a comment)
+
| REM (Startet eine Kommentierung)
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 283: Line 266:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| DIM
+
| DIM (legt den Typ einer Variablen fest)
 
|}
 
|}
 
</div>
 
</div>
Line 290: Line 273:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
A "comment" is a non-executable statement used to clarify a programs operation and purpose.
+
Eine Kommentierung (Comment) ist eine "nicht ausführbare Anweisung" und dient dazu Schritte im Programm zu beschreiben oder verdeutlichen. Verwenden sie gerade zu Beginn viele Kommentierungen, damit sie sich selbst den Sinn und Zweck von Befehlszeilen verdeutlichen.
  
A comment is introduced by the REM statement or a single quote character(').
+
Eine Kommentierung wird mit dem Befehl (REM) oder einem einfachen Anführungszeichen (') eingeleitet. Solch eine Kommentierung hat lediglich in der betreffenden Zeile Gültigkeit. (siehe auch Blockkommentierung)
  
The following lines are equivalent:
+
Die folgenden Zeilen bewirken das gleiche:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 302: Line 285:
 
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp;</span>
 
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp;</span>
  
More than one BASCOM statement can be placed on a line, but colons(:) must separate statements, as illustrated below.
+
Es können mehrere BASCOM Befehle in einer Zeile stehen, diese müssen aber mit einem Doppelpunkt von einander getrennt sein, wie nachfolgendes Beispiel zeigt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 312: Line 295:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">BASCOM LineLength</span> =
+
= <span class="f_Header">BASCOM Zeilenlänge</span> =
  
If you enter your programs using the built-in editor, you are not limited to any line length, although it is advised to shorten your lines to 80 characters for clarity.
+
Wenn sie den BASCOM eigenen Editor benutzen, ist die Länge einer Zeile nicht beschränkt. Zur besseren Übersicht wird aber dazu geraten, die Zeile auf 80 Zeichen zu beschränken.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 320: Line 303:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Data Types</span> =
+
= <span class="f_Header">Datentypen</span> =
  
Every variable in BASCOM has a data type that determines what can be stored in the variable. The next section summarizes the elementary data types.
+
Jede BASCOM Variable ist einem Datentyp zugeordnet. Hiervon hängt ab, welcher Wert in einer Variablen gespeichert werden kann. Der nächste Abschnitt beschreibt die elementaren Datentypen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 330: Line 313:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Elementary Data Types</span> =
+
= <span class="f_Header">Elementare Datentypen</span> =
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 337: Line 320:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Bit (1/8 byte). A bit can hold only the value 0 or 1. A group of 8 bits is called a byte.
+
| Bit (1/8 Byte). Ein BIT kann nur genau eine Informationseinheit speichern. Dies ist entweder eine 0 oder eine 1. Eine Gruppe von 8 Bit nennt man 1 BYTE.
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 343: Line 326:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Byte (1 byte). &nbsp;Bytes are stores as unsigned 8-bit binary numbers ranging in value from 0 to 255.
+
| Byte (1 Byte). &nbsp;Bytes werden als "unsigned" (vorzeichenlos) 8-Bit Werte gespeichert. Ein Byte kann eine natürliche Zahl im Bereich von 0 bis 255 darstellen. (nicht negative ganze Zahl)
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 349: Line 332:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Integer (two bytes). Integers are stored as signed sixteen-bit binary numbers ranging in value from -32,768 to +32,767.
+
| Integer (zwei Byte). Integer wird als "signed" (vorzeichenbehaftet) 16-Bit binäre Zahl gespeichert. Der darstellbare Zahlenraum liegt hierbei von -32.768 bis +32.767
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 355: Line 338:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Word (two bytes). Words are stored as unsigned sixteen-bit binary numbers ranging in value from 0 to 65535.
+
| Word (zwei Byte). WORD wird als "unsigned" (vorzeichenlos) 16-Bit Werte gespeichert. Ein Word kann eine natürliche Zahl im Bereich von 0 bis 65535 darstellen.
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 361: Line 344:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Dword(fout bytes). Dwords are stored as unsigned 32-bit unsigned numbers ranging in value from 0 to 4294967295
+
| Dword (vier Byte). DWORD wird als "unsigned" (vorzeichenlos) 32-Bit Werte gespeichert. Ein DWord kann eine natürliche Zahl im Bereich von 0 bis 4294967295 darstellen.
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 367: Line 350:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Long (four bytes). Longs are stored as signed 32-bit binary numbers ranging in value from -2147483648 to 2147483647.
+
| Long (vier Byte). Integer wird als "signed" (vorzeichenbehaftet) 32-Bit binäre Zahl gespeichert. Der darstellbare Zahlenraum liegt hierbei von -2147483648 bis 2147483647.
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 373: Line 356:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Single. Singles are stored as signed 32 bit binary numbers. Ranging in value from 1.5 x 10^–45 to 3.4 x 10^38
+
| Single (vier Byte). Singles wird als "signed" (vorzeichenbehaftet) 32-Bit binäre Zahl gespeichert. Der darstellbare Zahlenraum liegt hierbei von 1.5 x 10^–45 bis 3.4 x 10^38
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 379: Line 362:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Double. Doubles are stored as signed 64 bit binary numbers. Ranging in value from 5.0 x 10^–324 to 1.7 x 10^308
+
| Double (acht Byte). Double wird als "signed" (vorzeichenbehaftet) 64-Bit binäre Zahl gespeichert.Der darstellbare Zahlenraum liegt hierbei von 5.0 x 10^–324 bis 1.7 x 10^308
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 385: Line 368:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| String (up to 254 bytes). Strings are stored as bytes and are terminated with a 0-byte. A string dimensioned with a length of 10 bytes will occupy 11 bytes.
+
| String (bis zu 254 Byte). String (Zeichenkette) wird als Folge von Bytes gespeichert mit abschließenden Byte mit Wert 0. Ein String mit einer Länge von 10 Zeichen belegt 11 Byte Speicher.
 
|}
 
|}
 
</div>
 
</div>
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Variables can be stored internal (default) , external or in EEPROM.
+
Variablen können intern (Standard), extern oder im EEPROM gespeichert werden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 396: Line 379:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Variables</span> =
+
= <span class="f_Header">Variablen</span> =
  
A variable is a name that refers to an object--a particular number.
+
Eine Variable ist ein Name, welcher auf ein Objekt in einem Speicherbereich zeigt
  
A numeric variable, can be assigned only a numeric value (either integer, byte, long, single or bit).
+
Einer numerischen Variable kann, ihrer Definition entsprechend, nur eine Zahl zugewiesen werden.
  
The following list shows some examples of variable assignments:
+
Im Folgenden ein paar Beispiele von Variablen Zuweisungen:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 409: Line 392:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| A constant value:
+
| Einen konstanten Wert zuweisen:
 
|}
 
|}
 
</div>
 
</div>
Line 421: Line 404:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| The value of another numeric variable:
+
| Den Wert einer anderen Variable einer Variable zuweisen:
 
|}
 
|}
 
</div>
 
</div>
Line 433: Line 416:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| The value obtained by combining other variables, constants, and operators: Temp = a + 5
+
| Den Wert durch die Kombination von anderen Variablen, Konstanten und Operatoren erhalten: Temp = a + 5
 
|}
 
|}
 
</div>
 
</div>
Line 443: Line 426:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| The value obtained by calling a function:
+
| Den Wert durch Aufruf einer Funktion erhalten:
 
|}
 
|}
 
</div>
 
</div>
Line 452: Line 435:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Variable Names</span> =
+
= <span class="f_Header">Variablen Namen</span> =
  
A BASCOM variable name may contain up to 32 characters.
+
Ein BASCOM Variablen Name kann bis zu 32 Zeichen lang sein.
  
The characters allowed in a variable name are letters and numbers.
+
Der Name darf Buchstaben und Zahlen enthalten.
  
The first character in a variable name must be a letter.
+
Das erste Zeichen des Namen muss ein Buchstabe sein
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
A variable name cannot be a reserved word, but embedded reserved words are allowed.
+
Ein Variablenname darf kein reserviertes Wort sein, aber kann es beinhalten.
  
For example, the following statement is illegal because AND is a reserved word.
+
Die Anweisung im folgenden Beispiel ist nicht erlaubt, da AND ein reserviertes Wort ist:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 472: Line 455:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
However, the following statement is legal:
+
Die Anweisung im folgenden Beispiel ist gültig:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 482: Line 465:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Reserved words include all BASCOM commands, statements, function names, internal registers and operator names.
+
Reservierte Wörter umfassen alle BASCOM Befehle, Ausdrücke, Funktion, interne Register und Operatoren.
  
(see&nbsp;[[Reserved Words|BASCOM Reserved Words]]&nbsp;, for a complete list of reserved words).
+
(siehe&nbsp;[[Reserved Words|BASCOM Reservierte Wörter]], für eine Liste mit allen reservierten Wörtern).
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
You can specify a hexadecimal or binary number with the prefix &H or &B.
+
Hexadezimal Zahlen werden mit &H angegeben. Binäre Zahlen werden mit &B angegeben.
  
a = &HA , a = &B1010 and a = 10 are all the same.
+
a = &HA , a = &B1010 und a = 10 weist der Variablen das Gleiche zu.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Before assigning a variable, you must tell the compiler about it with the&nbsp;[[DIM]]&nbsp;statement.
+
Vor der Benutzung einer Variable, muss diese dem Compiler durch eine &nbsp;[[DIM]]&nbsp; Anweisung bekannt gemacht werden.
  
 
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;b1&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Bit</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;I&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">as</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Integer</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;k&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">as</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;s&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">String</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">*</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;10</span>
 
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;b1&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Bit</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;I&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">as</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Integer</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;k&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">as</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;s&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">String</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">*</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;10</span>
Line 500: Line 483:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The STRING type needs an additional parameter to specify the length.
+
Bei dem Variablentyp STRING muss zusätzlich die Länge des String angegeben werden
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 506: Line 489:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
You can also use&nbsp;[[DEFXXX|DEFINT]],&nbsp;[[DEFXXX|DEFBIT]],&nbsp;[[DEFXXX|DEFBYTE]]&nbsp;,[[DEFXXX|DEFWORD]]&nbsp;,[[DEFXXX|DEFLNG]]&nbsp;or&nbsp;[[DEFXXX|DEFSNG]].
+
Ebenfalls möglich:&nbsp;[[DEFXXX|DEFINT]],&nbsp;[[DEFXXX|DEFBIT]],&nbsp;[[DEFXXX|DEFBYTE]]&nbsp;,[[DEFXXX|DEFWORD]]&nbsp;,[[DEFXXX|DEFLNG]]&nbsp;or&nbsp;[[DEFXXX|DEFSNG]].
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
For example,DEFINT c tells the compiler that all variables that are not dimensioned and that are beginning with the character c are of the Integer type.
+
Beispiel: DEFINT c teilt dem Compiler mit, dass alle undefinierten Variablen welche mit dem Zeichen "c" anfangen, vom Typ INTEGER sind.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 516: Line 499:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Expressions and Operators</span> =
+
= <span class="f_Header">Ausdrücke und Operatoren</span> =
  
This chapter discusses how to combine, modify, compare, or get information about expressions by using the operators available in BASCOM.
+
Dieses Kapitel beschreibt, wie man Ausdrücke und Operatoren in BASCOM anwendet.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Anytime you do a calculation you are using expressions and operators.
+
Bei jeder Berechnung werden Ausdrücke und Operatoren verwendet.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This chapter describes how expressions are formed and concludes by describing the following kind of operators:
+
Dieses Kapitel beschreibt, wie Ausdrücke gebildet werden und schließt mit der Beschreibung der Art von Operatoren:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 533: Line 516:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Arithmetic operators, used to perform calculations.
+
| Arithmetische Operatoren, werden für Berechnungen verwendet.
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 539: Line 522:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Relational operators, used to compare numeric or string values.
+
| Verhältnis (Relational) Operatoren, Vergleich von numerischen oder auch String Variablen.
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 545: Line 528:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Logical operators, used to test conditions or manipulate individual bits.
+
| Logische Operatoren, Testen von Bedingungen oder Veränderung von Bits.
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px 0px 0px 11px;">
Line 551: Line 534:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Functional operators, used to supplement simple operators.
+
| Funktions Operatoren, zur Ergänzung der einfachen Operatoren.
 
|}
 
|}
 
</div>
 
</div>
Line 560: Line 543:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Expressions and Operators</span> =
+
<br/>Ein Ausdruck kann eine numerische Konstante, eine Variable oder ein einzelner Wert durch die Kombination von Konstanten, Variablen und andere Ausdrücken mit Operatoren sein.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
An expression can be a numeric constant, a variable, or a single value obtained by combining constants, variables, and other expressions with operators.
+
Operatoren führen mathematische oder logischen Operationen an Werten durch.
  
<span style="font-family: Arial;">&nbsp;</span>
+
Die von BASCOM zur Verfügung stehenden Operatoren sind in vier Gruppen einzuordnen:
 
+
Operators perform mathematical or logical operations on values.
+
 
+
The operators provided by BASCOM can be divided into four categories, as follows:
+
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
1. Arithmetic
+
1. Arithmetisch
  
2. Relational
+
2. Verhältnis (Relational)
  
3. Logical
+
3. Logisch
  
4. Functional
+
4. Funktionen
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 588: Line 567:
 
= <span class="f_Header">Arithmetic</span> =
 
= <span class="f_Header">Arithmetic</span> =
  
Arithmetic operators are +, - , * , \, / and ^.
+
Arithmetische Operatoren sind +, - , * , \, / und ^.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 598: Line 577:
 
|}
 
|}
 
</div>
 
</div>
Integer division is denoted by the backslash (\).
+
Integer Division wird durch den Schrägstrich rückwärts (\)(Backslash) dargestellt.
  
Example: Z = X \ Y
+
Beispiel: Z = X \ Y
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 607: Line 586:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Modulo Arithmetic
+
| Modulo Arithmetik
 
|}
 
|}
 
</div>
 
</div>
Modulo arithmetic is denoted by the modulus operator MOD.
+
Modulo Arithmetik wird mit MOD durchgeführt.
  
Modulo arithmetic provides the remainder, rather than the quotient, of &nbsp; an integer division.
+
Eine Modulo Arithmetik ergibt den Teilungsrest einer ganzzahligen Division.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Example: X = 10 \ 4&nbsp;: remainder = 10 MOD 4
+
Beispiel: X = 10 \ 4&nbsp;: Teilungsrest= 10 MOD 4
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 623: Line 602:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Overflow and division by zero
+
| Overflow und "Division by zero" (Überlauf und Teilung durch 0)
 
|}
 
|}
 
</div>
 
</div>
Division by zero, produces an error.
+
"Division by zero" oder Teilung durch 0, erzeugt einen Fehler.
  
At the moment no message is produced, so you have to make sure yourself that this won't happen.
+
Hierbei findet keine Fehlerausgabe statt, sie müssen selbst dafür Sorge tragen, dass dies nicht eintreten kann.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 634: Line 613:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Relational Operators</span> =
+
= <span class="f_Header">Relationale Operatoren (Verhältnis Operatoren)</span> =
  
Relational operators are used to compare two values as shown in the table below.
+
Relationale Operatoren werden verwendet, um zwei Werte miteinander zu vergleichen. Die Operatoren sind in folgender Tabelle aufgelistet.
  
The result can be used to make a decision regarding program flow.
+
Das Ergebnis kann verwendet werden, um den Programmablauf zu steuern.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 648: Line 627:
  
 
| valign="top" width="100%" bgcolor="#ffffb2" style="width: 65px; background-color: rgb(255, 255, 178); border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" bgcolor="#ffffb2" style="width: 65px; background-color: rgb(255, 255, 178); border: 1px solid rgb(0, 0, 0);" |  
<span style="font-weight: bold;">Relation Tested</span>
+
<span style="font-weight: bold;">Vergleich</span>
  
 
| valign="top" width="100%" bgcolor="#ffffb2" style="width: 80px; background-color: rgb(255, 255, 178); border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" bgcolor="#ffffb2" style="width: 80px; background-color: rgb(255, 255, 178); border: 1px solid rgb(0, 0, 0);" |  
<span style="font-weight: bold;">Expression</span>
+
<span style="font-weight: bold;">Ausdruck</span>
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 658: Line 637:
  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
Equality
+
gleich
  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
Line 668: Line 647:
  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
Inequality
+
unterschiedlich
  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
Line 678: Line 657:
  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
Less than
+
kleiner als
  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
Line 688: Line 667:
  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
Greater than
+
größer als
  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
Line 698: Line 677:
  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
Less than or equal to
+
kleiner oder gleich
  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
Line 708: Line 687:
  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 65px; border: 1px solid rgb(0, 0, 0);" |  
Greater than or equal to
+
größer oder gleich
  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 80px; border: 1px solid rgb(0, 0, 0);" |  
Line 719: Line 698:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Logical Operators</span> =
+
= <span class="f_Header">Logische Operatoren</span> =
  
Logical operators perform tests on relations, bit manipulations, or Boolean operators.
+
Logische Operatoren prüfen Bits, manipulieren Bits oder sind boolsche Operatoren.
  
There four operators in BASCOM are&nbsp;:
+
Es gibt in BASCOM vier logische Operatoren&nbsp;:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 733: Line 712:
  
 
| valign="top" width="100%" bgcolor="#ffff99" style="width: 79px; background-color: rgb(255, 255, 153); border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" bgcolor="#ffff99" style="width: 79px; background-color: rgb(255, 255, 153); border: 1px solid rgb(0, 0, 0);" |  
<span style="font-weight: bold;">Meaning</span>
+
<span style="font-weight: bold;">Bedeutung</span>
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 740: Line 719:
  
 
| valign="top" width="100%" style="width: 79px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 79px; border: 1px solid rgb(0, 0, 0);" |  
Logical complement
+
Logisches Komplementär
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 747: Line 726:
  
 
| valign="top" width="100%" style="width: 79px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 79px; border: 1px solid rgb(0, 0, 0);" |  
Conjunction
+
logisches UND
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 754: Line 733:
  
 
| valign="top" width="100%" style="width: 79px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 79px; border: 1px solid rgb(0, 0, 0);" |  
Disjunction
+
logisches ODER
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 761: Line 740:
  
 
| valign="top" width="100%" style="width: 79px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 79px; border: 1px solid rgb(0, 0, 0);" |  
Exclusive or
+
Exclusiv ODER (Exclusive or)
  
 
|}
 
|}
Line 767: Line 746:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
It is possible to use logical operators to test bytes for a particular bit pattern.
+
Es ist möglich logische Operatoren zu verwenden, um Bytes auf Bitmuster zu testen.
  
For example the AND operator can be used to mask all but one of the bits of a status byte, while OR can be used to merge two bytes to create a particular binary value.
+
Zum Beispiel kann der AND Operator dazu benutzt werden, alle bis auf ein BIT auszumaskieren. Der OR Operator kann dazu benutzt werden, um zwei Bytes zu einem neuen Wert zusammen zu fassen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 775: Line 754:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Example</span> =
+
Beispiel:
  
 
<span style="font-size: 8pt; font-family: Courier;">A&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;63&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 128);">And</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;19</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">PRINT</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span><br/><span style="font-size: 8pt; font-family: Courier;">A&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;10&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Or</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;9</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">PRINT</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span>
 
<span style="font-size: 8pt; font-family: Courier;">A&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;63&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 128);">And</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;19</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">PRINT</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span><br/><span style="font-size: 8pt; font-family: Courier;">A&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;10&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Or</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;9</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">PRINT</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span>
Line 783: Line 762:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Output</span> =
+
Ausgabe:
  
 
19
 
19
Line 795: Line 774:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Floating point SINGLE (4 BYTE)(ASM code used is supplied by Jack Tidwell)
+
Fließkomma SINGLE (4 BYTE)
  
Single numbers conforming to the IEEE binary floating point standard.
+
SINGLE Zahlen entsprechen dem IEEE Fließkomma Standard.
  
An eight bit exponent and 24 bit mantissa are supported.
+
Ein Acht-Bit-Exponent und 24 Bit Mantisse werden unterstützt.
  
Using four bytes the format is shown below:
+
Bei Verwendung von vier Byte ergibt sich folgendes Ergebnis:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 811: Line 790:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
s exponent mantissa
+
s Exponent Mantisse
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 817: Line 796:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The exponent is biased by 128. Above 128 are positive exponents and below are negative. The sign bit is 0 for positive numbers and 1 for negative. The mantissa is stored in hidden bit normalized format so that 24 bits of precision can be obtained.
+
Der Exponent wird durch 128 vorgeladen. Oberhalb 128 sind positive Exponenten, unterhalb sind Negative. Das Vorzeichenbit für positive Zahlen ist 0 und 1 für Negative. Die Mantisse wird in einem versteckten Bit in normalisiertem Format gespeichert, so dass 24 Bits Präzision erreicht werden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
All mathematical operations are supported by the single.
+
Alle mathematischen Operationen werden durch SINGLE unterstützt
  
You can also convert a single to an integer or word or vise versa:
+
Sie können einen SINGLE zu einem INTEGER oder WORD konvertieren oder anders herum.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 831: Line 810:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
S = 100.1 'assign the single
+
S = 100.1 'Ein SINGLE zuweisen
  
I = S &nbsp;'will convert the single to an integer
+
I = S &nbsp;'Konvertiert den SINGLE zu einem WORD
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 839: Line 818:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Here is a fragment from the Microsoft knowledge base about FP:
+
Hier ein Auszug aus der "Microsoft knowledge base" über FP (Fließkomma):
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 851: Line 830:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Decimal and Binary Number Systems</span> =
+
= <span class="f_Header">Dezimale und binäre Zahlensysteme</span> =
  
Normally, we count things in base 10. The base is completely arbitrary. The only reason that people have traditionally used base 10 is that they have 10 fingers, which have made handy counting tools.
+
Normalerweise rechnen wir im 10er Zahlensystem, dem Dezimalsystem.
 +
 
 +
Die Basis 10 ist dabei völlig willkürlich gewählt. Der einzige Grund mit der Basis von 10 zu rechnen ist, das Menschen mit ihren 10 Fingern arbeiteten um Berechnungen durchzuführen.
 +
 
 +
<br/>Zur Verdeutlichung:
 +
 
 +
Rechnen in einem Zahlensystem mit der Basis 10 bedeutet, dass ein Übertrag zur nächsten Stelle nach der Verwendung der 10 möglichen Zeichen stattfindet. Der Zeichenvorrat im Dezimalsystem ist also 10. (0,1,2,3,4,5,6,7,8,9) Die Wertigkeit der Stellen ist demnach: 1, 10, 100, 1000 und so weiter. Ein negativer Exponent, z.B. 10^-1 stellt den Nachkommawert dar. 10^-1 ist hiernach 1/10, 10^-2 = 1/100, 10^-3 = 1/1000 usw.
 +
 
 +
<br/>Die Zahl 101 im Dezimalsystem drückt folgendes aus: (1 * 100) + (0 * 10) + (1 * 1) = 101 (dezimal)
 +
 
 +
<br/>Im Binärsystem (Zweierzahlensystem) ist der Zeichenvorrat genau zwei Zeichen groß: 0 und 1. Nach der Verwendung der 1, erfolgt bereits ein Übertrag zur nächsten Stelle. Hier ist die Wertigkeit der Stellen: 1, 2, 4, 8, 16 und so weiter. Ein negativer Exponent, z.B. 2^-1 stellt den Nachkommawert dar. 2^-1 ist hiernach 1/2, 10^-2 = 1/4, 10^-2 = 1/8 usw.
 +
 
 +
<br/>Die Zahl 101 im Binärsystem drückt folgendes aus: (1 * 4) + (0 * 2) + (1 * 1) = 101 (binär) = 5 (dezimal)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 859: Line 850:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The number 532.25 in decimal (base 10) means the following:
+
Die dezimale Darstellung der Zahl 532,25 sieht wie folgt aus:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 879: Line 870:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
In the binary number system (base 2), each column represents a power of 2 instead of 10. For example, the number 101.01 means the following:
+
Im binären Zahlensystem ist die Basis 2, im Gegensatz zum dezimalen, wo die Basis 10 lautet. Darstellung der Zahl 101,01 im Binärsystem:
  
 
(1 * 2^2) + (0 * 2^1) + (1 * 2^0) + (0 * 2^-1) + (1 * 2^-2)
 
(1 * 2^2) + (0 * 2^1) + (1 * 2^0) + (0 * 2^-1) + (1 * 2^-2)
Line 893: Line 884:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
How Integers Are Represented in PCs
+
Wie INTEGER in Rechnern dargestellt werden
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 899: Line 890:
 
----
 
----
  
Because there is no fractional part to an integer, its machine representation is much simpler than it is for floating-point values. Normal integers on personal computers (PCs) are 2 bytes (16 bits) long with the most significant bit indicating the sign. Long integers are 4 bytes long.
+
Da es keinen Bruchteil (Nachkommawert) bei INTEGER gibt, ist die Darstellung sehr viel einfacher als für Fließkommazahlen. Es handelt sich also um ganze Zahlen. Normalerweise sind INTEGER in Rechnern zwei BYTE (16 BIT) groß. Das höchstwertige BIT zeigt das Vorzeichen an (positive oder negative Ganzzahl). Neben einem INTEGER gibt es auch einen LONGINTEGER, welcher vier Byte umfasst.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Positive values are straightforward binary numbers. For example:
+
Positive Zahlenwerte sind einfache binäre Zahlen. Zum Beispiel:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 909: Line 900:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
1 Decimal = 1 Binary
+
1 dezimal = 1 binär
  
2 Decimal = 10 Binary
+
2 dezimal = 10 binär
  
22 Decimal = 10110 Binary, etc.
+
22 dezimal = 10110 binär, usw.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
However, negative integers are represented using the two's complement scheme. To get the two's complement representation for a negative number, take the binary representation for the number's absolute value and then flip all the bits and add 1. For example:
+
Negative INTEGER werden durch das Zweierkomplement dargestellt. Um das Zweierkomplement einer negativen Zahl zu erhalten, wird die Zahl zunächst binär als positive Ganzzahl im INTEGER dargestellt. Danach werden alle BITs des INTEGER umgekehrt. Als letzten Schritt wird der Wert 1 addiert.
 +
 
 +
 
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 923: Line 916:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
4 Decimal = 0000 0000 0000 0100
+
4 dezimal = 0000 0000 0000 0100
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
1111 1111 1111 1011 Flip the Bits
+
1111 1111 1111 1011 Alle Bits umkehren (Flip the Bits)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
-4 = 1111 1111 1111 1100 Add 1
+
-4 = 1111 1111 1111 1100 Zahl 1 addieren (Add 1)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 937: Line 930:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Note that adding any combination of two's complement numbers together
+
Bei der Addition zweier Zahlen im Zweier-Komplement kommt immer das richtige Ergebnis heraus - <span style="font-family: Arial;">&nbsp;</span>
  
<span style="font-family: Arial;">&nbsp;</span>
+
auch wenn eine oder beide Zahlen negative Zahlen darstellen.
 
+
using ordinary binary arithmetic produces the correct result.
+
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 947: Line 938:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Floating-Point Complications</span> =
+
= <span class="f_Header">Fließkomma Zahlenfehler</span> =
  
Every decimal integer can be exactly represented by a binary integer; however, this is not true for fractional numbers. In fact, every number that is irrational in base 10 will also be irrational in any system with a base smaller than 10.
+
Jeder dezimal INTEGER Wert (rationale Zahl!) kann exakt Binär dargestellt werden. Dies gilt nicht für Fließkomma Zahlen (irrationale Zahl)! Eine irrationale Zahl ist eine reelle Zahl, die keine rationale Zahl ist. Eine irrationale Zahl ist dadurch gekennzeichnet, dass sie kein Verhältnis von ganzen Zahlen ist. Eine reelle Zahl heißt irrational, wenn sie nicht als Bruch zweier ganzer Zahlen dargestellt werden kann. Eine bekannte irrationale Zahl ist PI.
 +
 
 +
<br/>Merke: Jede irrationale Zahl im Dezimalsystem ist in jedem anderen Zahlensystem irrational!
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
For binary, in particular, only fractional numbers that can be represented in the form p/q, where q is an integer power of 2, can be expressed exactly, with a finite number of bits.
+
Für das Binärsystem im Besonderen gilt: Jede Bruchteil einer ganzen Zahl ("Nachkommawert"), in der Form p/q (wobei q eine ganzzahlige Potenz von 2 ist), kann exakt dargestellt werden mit einer endlichen Anzahl von BIT.
  
<span style="font-family: Arial;">&nbsp;</span>
+
<br/><span style="font-family: Arial;">&nbsp;</span>
  
Even common decimal fractions, such as decimal 0.0001, cannot be represented exactly in binary. (0.0001 is a repeating binary fraction with a period of 104 bits!)
+
Auch Dezimalbrüche wie 1/10000 oder 0,0001 können Binär nicht exakt dargestellt werden. Hierbei liegt die Periode bei 104 BIT (periodische Wiederkehr von Teilungsbrüchen).
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 963: Line 956:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This explains why a simple example, such as the following
+
Dies erklärt, warum bei diesem einfachen Beispiel...
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 973: Line 966:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
will PRINT 1.000054 as output. The small error in representing 0.0001
+
1.000054 ausgegeben wird. Ein kleiner Fehler macht sich bei der Darstellung der Summierung von 0.0001 bemerkbar!
 
+
in binary propagates to the sum.
+
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 981: Line 972:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
For the same reason, you should always be very cautious when making comparisons on real numbers. The following example illustrates a common programming error:
+
Aus diesem Grund sollten sie sehr vorsichtig mit dem Vergleich reeller Zahlen umgehen. Das folgende Beispiel zeigt einen häufig begangenen Programmierfehler:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 997: Line 988:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This will NOT PRINT "Equality!" because 69.82 cannot be represented exactly in binary, which causes the value that results from the assignment to be SLIGHTLY different (in binary) than the value that is generated from the expression. In practice, you should always code such comparisons in such a way as to allow for some tolerance.
+
Dies wird NICHT "Equality!" (GLEICH) AUSGEBEN, weil 69.82 im Binärsystem nicht exakt dargestellt werden kann. Der Wert der binären Berechnung unterscheidet sich also geringfügig von dem direkt zugewiesenen Wert. In der Praxis sollten sie diesen Vergleich mit einer gewissen Toleranz ausführen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,005: Line 996:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">General Floating-Point Concepts</span> =
+
= <span class="f_Header">Allgemeine Fließkommazahlen Konzepte</span> =
  
It is very important to realize that any binary floating-point system can represent only a finite number of floating-point values in exact form. All other values must be approximated by the closest represent able value. The IEEE standard specifies the method for rounding values to the "closest" represent able value. BASCOM supports the standard and rounds according to the IEEE rules.
+
Es ist sehr wichtig zu verstehen, dass jedes Fließkommazahlen System nur eine endliche Anzahl von Fließkommazahlen exakt darstellen kann. Alle anderen Werte müssen zum nächstmöglichen darstellbaren Wert angenähert werden. Der IEEE Standard definiert die Methode zum nächstmöglichen darstellbaren Wert. BASCOM unterstützt diesen Standard und rundet nach den IEEE Spezifikationen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Also, keep in mind that the numbers that can be represented in IEEE are spread out over a very wide range. You can imagine them on a number line. There is a high density of represent able numbers near 1.0 and -1.0 but fewer and fewer as you go towards 0 or infinity.
+
Denken sie bitte auch daran, dass Zahlendarstellungen nach dem IEEE Standard eine große Streuung beinhalten können. Es gibt eine hohe Genauigkeit im Bereich zwischen 1,0 und -1,0, aber je näher sie sich der 0 oder unendlich großen Zahlen annähern, je ungenauer wird das Ergebnis sein.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The goal of the IEEE standard, which is designed for engineering calculations, is to maximize accuracy (to get as close as possible to the actual number). Precision refers to the number of digits that you can represent. The IEEE standard attempts to balance the number of bits dedicated to the exponent with the number of bits used for the fractional part of the number, to keep both accuracy and precision within acceptable limits.
+
Der Vorteil des IEEE Standard, welcher für technische Berechnungen konzipiert wurde, ist die Genauigkeit zu maximieren (so nah als möglich dem richtigen Ergebnis zu sein). Präzision ist hier gleichbedeutend der Anzahl der darstellbaren Stellen. Der IEEE Standard empfiehlt hier eine Balance zwischen den BITs für den Exponent und den BITs für den Nachkommaanteil zu finden, um sowohl Genauigkeit als auch Präzision in akzeptablen Grenzen zu halten.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
 +
 +
'''Erläuterung zur Exponentialdarstellung:'''
 +
 +
Praktisch alle Mikroprozessoren beherrschen zunächst nur den Umgang mit ganzen Zahlen, den sogenannten Integer-Zahlen.
 +
 +
Bei der Speicherung einer Fließkommazahl im binären System, muss das Komma zusammen mit der eigentlichen Zahl gespeichert werden. Das Komma ist keine feststehende Position innerhalb einer beliebigen Fließkommazahl. Beispiel hierzu: 0,12 1234,5 Die eigentliche Zahl einer Fließkommazahl ist die reine Ziffernfolge der Zahl, ohne das Komma. Man nennt sie auch Mantisse. Beispiel: 123,45 --> Mantisse 12345 Die Kommastellung zur Mantisse relativ zur Mantisse wird durch einen Exponenten angegeben. Bei negativen Exponenten wird das Komma nach links verschoben, positive Exponenten verschieben das Komma nach rechts.
 +
 +
<br/>Merke: Eine Zahl mit Komma ist also durch zwei ganze Zahlen dargestellt.
 +
 +
<br/>Einen EURO Betrag von 12,34 kann man also durch die Mantisse 1234 und den Exponenten -2 abspeichern. Bei diesem Beispiel würden wir aber bei Exponent=0 implizieren, dass das Komma hinter der letzten Ziffer (also am rechten Ende) der Mantisse stehen würde.
 +
 +
<br/>In der Praxis verwendet man allerdings eine "normalisierte Darstellung". Dabei steht das Komma hinter der ersten Stelle, welche ungleich 0 ist. Diese Darstellung ist als "wissenschaftliche Darstellung" bekannt und wird von jedem Taschenrechner unterstützt.
 +
 +
<br/>Unser obiges Beispiel in wissenschaftlicher Darstellung sieht wie folgt aus: aus 12,34 wird die Mantisse 1,234 und der Exponent 1 (also Komma um eine Stelle nach rechts schieben)
 +
 +
Diese Betrachtung gilt für die Normalisierung einer Dezimalzahl mit dem Zeichenvorrat von 0 bis 9. Demnach könnte die Mantisse einer Dezimalzahl also an der ersten Stelle eine Zahl zwischen 0 und 9 sein.
 +
 +
<br/>Anders ist es bei der Darstellung dieser Zahl im binären Zahlensystem. Hier haben wir nur zwei Zeichen zur Verfügung. Nachdem führende Nullen in der Binärzahl keine Bedeutung haben, ist die erste Stelle einer Zahl im Binärsystem bei wissenschaftlicher Darstellung also immer eine 1. Dieser 1 folgt das Komma und weitere Ziffern. Die Mantisse kann nun in zwei Teile zerlegt werden:
 +
 +
- den Vorkommateil (also die führende 1)
 +
 +
- den Nachkommateil (engl. "fraction" oder in deutsch "Bruchteil") auch bezeichnet als Binärbruch
 +
 +
<br/>Die Schreibweise „1e9" ist eine Abkürzung für 1 x 10^9, also für den Wert 1 000 000 000, eine Eins mit neun Nullen. Man nennt dies die Exponentialdarstellung. Im Binärsystem lautet die Exponentialdarstellung beispielsweise: „1e101" (ist eine Abkürzung für 1 x 2^5). Das Zeichen „e" wird also immer gegen die Basis des jeweiligen Zahlensystems ausgetauscht (10 für Dezimalsystem, 2 für Binärsystem, 16 für Hexadezimalsystem). Die Zahl 100,0 entspricht 1,0 x 10^2 - eine Verschiebung des Kommas nach links entspricht einer Erhöhung des Exponenten. Die Zahl 0,001 entspricht 1,0 x 10^-3 - eine Verschiebung des Kommas nach rechts entspricht einer Verringerung des Exponenten.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,023: Line 1,038:
 
= <span class="f_Header">IEEE Details</span> =
 
= <span class="f_Header">IEEE Details</span> =
  
Floating-point numbers are represented in the following form, where
+
Fließkommazahlen werden in folgender Form dargestellt, wobei
  
[exponent] is the binary exponent:
+
[exponent] der binäre Exponent ist:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,033: Line 1,048:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
[Fraction] is the normalized fractional part of the number, normalized because the exponent is adjusted so that the leading bit is always a 1. This way, it does not have to be stored, and you get one more bit of precision. This is why there is an implied bit. You can think of this like scientific notation, where you manipulate the exponent to have one digit to the left of the decimal point, except in binary, you can always manipulate the exponent so that the first bit is a 1, since there are only 1s and 0s.
+
[Fraction] ist der normalisierte Teil des Bruchteil der Zahl. Normalisiert, weil hier der Exponent derart angepasst wird, dass führende Zahl immer 1 ist. Da diese immer 1 ist, muss diese nicht gespeichert werden und man erlangt dadurch eine Stelle mehr für die Präzision. Da eine binäre Zahl nur aus 0 und 1 besteht, kann man den Exponenten so lange ändern, bis eine 1 vor dem Komma steht.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
[bias] is the bias value used to avoid having to store negative exponents.
+
[bias] Der Vorgabewert (BIAS) wird verwendet um zu vermeiden, dass negative Exponenten gespeichert werden müssen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The bias for single-precision numbers is 127 and 1023 (decimal) for double-precision numbers.
+
Der BIAS Wert für einfache Präzision (single precision numbers) ist 127 (dez) und 1023 (dez) für doppelte Genauigkeit (double-precision numbers)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The values equal to all 0's and all 1's (binary) are reserved for representing special cases. There are other special cases as well, that indicate various error conditions.
+
Binäre Werte, bei denen alle Bit 0 oder 1 sind, sind speziellen Fällen vorbehalten. Es bestehen noch weitere spezielle Fälle, welche verschiedene Fehlerzustände darstellen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,051: Line 1,066:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Single-Precision Examples</span> =
+
= <span class="f_Header">Single-Precision Beispiele</span> =
  
 
2 = 1 * 2^1 = 0100 0000 0000 0000 ... 0000 0000 = 4000 0000 hex
 
2 = 1 * 2^1 = 0100 0000 0000 0000 ... 0000 0000 = 4000 0000 hex
  
Note the sign bit is zero, and the stored exponent is 128, or
+
Beachte, dass das Vorzeichenbit 0 ist und der Exponent 128, oder
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
100 0000 0 in binary, which is 127 plus 1. The stored mantissa is (1.)
+
100 0000 0 in Binärcode, welcher 127 + 1 ist. Die gespeicherte Mantisse ist (1.)
  
000 0000 ... 0000 0000, which has an implied leading 1 and binary point, so the actual mantissa is 1.
+
000 0000 ... 0000 0000, welche eine implizierte führende 1 hat. Die aktuelle Mantisse lautet also 1
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,069: Line 1,084:
 
-2 = -1 * 2^1 = 1100 0000 0000 0000 ... 0000 0000 = C000 0000 hex
 
-2 = -1 * 2^1 = 1100 0000 0000 0000 ... 0000 0000 = C000 0000 hex
  
Same as +2 except that the sign bit is set. This is true for all IEEE format floating-point numbers.
+
Das Gleiche wie +2, außer das das Vorzeichenbit gesetzt wurde. Dies gilt für alle IEEE-Format Gleitkommazahlen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,075: Line 1,090:
 
4 = 1 * 2^2 = 0100 0000 1000 0000 ... 0000 0000 = 4080 0000 hex
 
4 = 1 * 2^2 = 0100 0000 1000 0000 ... 0000 0000 = 4080 0000 hex
  
Same mantissa, exponent increases by one (biased value is 129, or 100 0000 1 in binary.
+
Gleiche Mantisse, aber Exponent durch 1 erhöht (BIAS Wert ist 129 oder 100 0000 1 in Binärcode)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,081: Line 1,096:
 
6 = 1.5 * 2^2 = 0100 0000 1100 0000 ... 0000 0000 = 40C0 0000 hex
 
6 = 1.5 * 2^2 = 0100 0000 1100 0000 ... 0000 0000 = 40C0 0000 hex
  
Same exponent, mantissa is larger by half -- it's
+
Gleicher Exponent, die Mantisse ist um die Hälfe größer -- es ist
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
(1.) 100 0000 ... 0000 0000, which, since this is a binary fraction, is 1-1/2 (the values of the fractional digits are 1/2, 1/4, 1/8, etc.).
+
(1.) 100 0000 ... 0000 0000, was, weil es sich um einen Binärbruch handelt, 1-1/2 (in Worten Ein und Einhalb)(die Werte eines Binärbruches sind 1/2, 1/4, 1/8, etc.).
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,091: Line 1,106:
 
1 = 1 * 2^0 = 0011 1111 1000 0000 ... 0000 0000 = 3F80 0000 hex
 
1 = 1 * 2^0 = 0011 1111 1000 0000 ... 0000 0000 = 3F80 0000 hex
  
Same exponent as other powers of 2, mantissa is one less than 2 at 127, or 011 1111 1 in binary.
+
Der gleiche Exponent wie bei anderen Potenzen von 2, Mantisse ist eins weniger als 2 von 127 in Binärcode 011 1111 1
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,099: Line 1,114:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The biased exponent is 126, 011 1111 0 in binary, and the mantissa is (1.) 100 0000 ... 0000 0000, which is 1-1/2.
+
Der vorgeladene ("biased") Exponent ist 126, im Binärcode 011 1111 0, und die Mantisse ist (1.) 100 0000 ... 0000 0000, was 1-1/2 entspricht.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,107: Line 1,122:
 
2.5 = 1.25 * 2^1 = 0100 0000 0010 0000 ... 0000 0000 = 4020 0000 hex
 
2.5 = 1.25 * 2^1 = 0100 0000 0010 0000 ... 0000 0000 = 4020 0000 hex
  
Exactly the same as 2 except that the bit which represents 1/4 is set in the mantissa.
+
Exakt das Gleiche wie 2, lediglich das BIT, welches 1/4 darstellt, ist in der Mantisse gesetzt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,117: Line 1,132:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
1/10 is a repeating fraction in binary. The mantissa is just shy of 1.6, and the biased exponent says that 1.6 is to be divided by 16 (it is 011 1101 1 in binary, which is 123 n decimal). The true exponent is 123 - 127 = -4, which means that the factor by which to multiply is 2**-4 = 1/16. Note that the stored mantissa is rounded up in the last bit. This is an attempt to represent the un-representable number as accurately as possible. (The reason that 1/10 and 1/100 are not exactly representable in binary is similar to the way that 1/3 is not exactly representable in decimal.)
+
1/10 ist ein sich immer wiederholender Nachkommaanteil im binären System (periodischer Teilungsrest). Die Mantisse liegt nahe dem Wert von 1,6 und der Exponent besagt, dass 1,6 durch 16 geteilt werden soll (es ist 011 1101 1 in binären Darstellung, also 123 in Dezimalzahl). Der tatsächliche Exponent ist 123 - 127 = -4 was bedeutet, dass der Faktor für die Multiplikation 2^-4 = 1/16 beträgt. Beachten Sie, dass die gespeicherte Mantisse in dem letzten Bit gerundet ist. Dies ist ein Versuch eine nicht darstellbare Zahl so genau wie möglich darzustellen. (Der Grund, dass 1/10 und 1/100 binärer nicht exakt dargestellt werden können ist ähnlich dem, dass 1/3 nicht exakt im dezimalen System dargestellt werden kann. Dies ergibt eben eine unendliche Periode von 3 --> 0,3333...)
  
<span style="font-family: Arial;">&nbsp;</span>
+
<br/><span style="font-family: Arial;">&nbsp;</span>
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
0 = 1.0 * 2^-128 = all zeros -- a special case.
+
0 = 1.0 * 2^-128 = Alles 0 -- ein spezieller Fall.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,129: Line 1,144:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Other Common Floating-Point Errors</span> =
+
= <span class="f_Header">Andere häufige Fließkommazahlen Fehler</span> =
  
The following are common floating-point errors:
+
Im folgenden sind häufige Fließkommazahl Fehler beschrieben:
  
 
&nbsp;
 
&nbsp;
  
1. Round-off error
+
1. Rundungsfehler
  
This error results when all of the bits in a binary number cannot be used in a calculation.
+
Dieser Fehler ergibt sich, wenn nicht alle Bits einer binären Zahl in einer Berechnung benutzt werden.
  
Example: Adding 0.0001 to 0.9900 (Single Precision)
+
Beispiel: Addiere 0.0001 bis 0.9900 (einfache Genauigkeit, "Single Precision")
  
Decimal 0.0001 will be represented as:
+
Dezimal 0.0001 wird dargestellt als:
  
(1.)10100011011011100010111 * 2^(-14+Bias) (13 Leading 0s in Binary!)
+
(1.)10100011011011100010111 * 2^(-14+Bias) (13 führende Nullen in Binärzahl!)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,149: Line 1,164:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
0.9900 will be represented as:
+
0.9900 wird dargestellt als:
  
 
(1.)11111010111000010100011 * 2^(-1+Bias)
 
(1.)11111010111000010100011 * 2^(-1+Bias)
Line 1,155: Line 1,170:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Now to actually add these numbers, the decimal (binary) points must be aligned. For this they must be Unnormalized. Here is the resulting addition:
+
Um nun diese Zahlen zu addieren, muss das binär Trennzeichen (Komma der Nachkommastellen) ausgerichtet werden. Eine Normalisierung ist dafür nicht notwendig. Hier ist die resultierende Addition:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
.000000000000011010001101 * 2^0 <- Only 11 of 23 Bits retained
+
.000000000000011010001101 * 2^0 <- Nur 11 von 23 Bits erhalten
  
 
+.111111010111000010100011 * 2^0
 
+.111111010111000010100011 * 2^0
Line 1,171: Line 1,186:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This is called a round-off error because some computers round when shifting for addition. Others simply truncate. Round-off errors are important to consider whenever you are adding or multiplying two very different values.
+
Dies wird als Rundungsfehler bezeichnet. Einige Rechner runden, wenn BITs zum Zweck der Addition geschoben werden, andere beschneiden das Ergebnis einfach. Es ist sehr wichtig Rundungsfehler zu beachten, wenn sie zwei sehr unterschiedliche Werte addieren oder multiplizieren.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,177: Line 1,192:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
2. Subtracting two almost equal values
+
2. Subtrahieren von zwei annähernd gleichen Werten
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,191: Line 1,206:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This will be normalized. Note that although the original numbers each had four significant digits, the result has only one significant digit.
+
Dies wird normalisiert werden. Beachten sie, dass das Ergebnis nur eine signifikante Ziffer hat obwohl die ursprünglichen Zahlen jeweils vier signifikante Stellen hatten.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,197: Line 1,212:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
3. Overflow and underflow
+
3. Überlauf und Unterlauf
  
This occurs when the result is too large or too small to be represented by the data type.
+
Dies passiert, wenn das Ergebnis einer Berechnung zu groß oder auch zu klein wird, um es im jeweiligen Datentyp darzustellen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,205: Line 1,220:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
4. Quantizing error
+
4. Quantisierungsfehler
 +
 
 +
Ist die Differenz aus der gestuften Näherung und dem (unverfälschten) Originalwert.
  
This occurs with those numbers that cannot be represented in exact form by the floating-point standard.
+
Tritt auf bei irrationale Zahlen, welche binär nicht dargestellt werden können.  
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,215: Line 1,232:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Rounding</span> =
+
= <span class="f_Header">Runden</span> =
  
When a Long is assigned to a single, the number is rounded according to the rules of the IEEE committee.
+
Wenn ein Long einem Single zugewiesen wird, wird die Zahl nach den Regeln des IEEE-Komitee abgerundet.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
For explanation: 1.500000 is exact the middle between 1.00000 and 2.000000. If x.500000 is always rounded up, than there is trend for higher values than the average of all numbers. So their rule says, half time to round up and half time to round down, if value behind LSB is exact ..500000000.
+
Zur Erläuterung: 1,500000 ist exakt die Mitte zwischen 1,000000 und 2,000000. Wird x,500000 immer aufgerundet, so ist der Trend aller Rundungen höher, als der Durchschnitt aller tatsächlichen Werte. Die Regel besagt aus diesem Grund abwechselnd auf- und abzurunden, wenn der Wert hinter dem LSB exakt ,500000000 ist.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The rule is, round this .500000000000 to next even number, that means if LSB is 1 (half time) to round up, so the LSB is going to 0 (=even), if LSB is 0 (other half time) to round down, that means no rounding.
+
Die Regel ist: Runde ,500000000000 zur nächsten ganzen Zahl auf. Bei der folgenden ,500000000000 wird nichts unternommen, der Bruchteil verfällt also.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This rounding method is best since the absolute error is 0.
+
Da dies im Wechsel stattfindet ist die Summe der Fehler 0 (NULL).
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
You can override the default IEEE rounding method by specifying the $LIB LONG2FLOAT.LBX library which rounds up to the next number. This is the method used up to 1.11.7.4 of the compiler.
+
Sie können die standard IEEE Rundungsmethode ändern, indem sie eine Library einbinden: $LIB LONG2FLOAT.LBX. Diese rundet immer zur nächsten Zahl auf. Diese Methode wurde bis zur Compilerversion 1.11.7.4 verwendet.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,243: Line 1,260:
 
= <span class="f_Header">Double</span> =
 
= <span class="f_Header">Double</span> =
  
The double is essential the same as a single. Except the double consist of 8 bytes instead of 4. The exponent is 11 bits leaving 52 bits for the mantissa.
+
Ein DOUBLE ist im Grunde das Gleiche wie ein SINGLE bis auf die Tatsache, dass ein DOUBLE 8 Byte anstelle von 4 Byte beim SINGLE verwendet. Der Exponent ist 11 BIT groß, damit verbleiben 52 BIT für die Mantisse.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,251: Line 1,268:
 
= <span class="f_Header">Arrays</span> =
 
= <span class="f_Header">Arrays</span> =
  
An array is a set of sequentially indexed elements having the same type. Each element of an array has a unique index number that identifies it. Changes made to an element of an array do not affect the other elements.
+
Ein Array ist eine Gruppe von fortlaufend indizierten Elementen gleichen Typs. Jedes Element eines Arrays hat eine eindeutige Index Nummer, die es identifiziert. Änderungen eines Elementes eines Array haben keinen Effekt auf die anderen Elemente.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The index must be a numeric constant, a byte, an integer, word or long.
+
Der Index muss eine numerische Konstante, ein Byte, ein Integer, ein Word oder ein Long sein.
  
The maximum number of elements is 65535. For Xmega with huge memory it is 8MB!
+
Die maximale Anzahl Elemente in einem Array beträgt 65535. Bei Xmega Typen mit großem Speicherbereich beträgt sie 8MB.
  
The first element of an array is always one by default. This means that elements are 1-based.
+
Der Index von Arrays ist 1 basierend d.h. das erste Element eines Array hat den Index 1.
  
You can change this with CONFIG BASE=0. In this case, the first element will be element 0.
+
Dies kann mit CONFIG BASE=0 geändert werden zu einem 0 basierenden Index. Der Index des erste Elementes des Array ist dann 0.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Arrays can be used on each place where a 'normal' variable is expected.
+
Array Elemente können überall dort verwendet werden, wo auch "normale" Variablen verwendet werden können.
  
 
&nbsp;
 
&nbsp;
  
You can add an offset to the index too. This could be used to emulate a 2 dimensional array.
+
Sie können auch einen Offset zu einem Index addieren. Dies kann benutzt werden, um zweidimensionale Arrays darzustellen.
  
 
row_index = row &nbsp;: &nbsp;shift row_index, left,4
 
row_index = row &nbsp;: &nbsp;shift row_index, left,4
Line 1,281: Line 1,298:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Example</span> =
+
= <span class="f_Header">Beispiel ARRAY</span> =
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'create an array named a, with 10 elements (1 to 10)</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">10</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'create an integer</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;C&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Integer</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'now fill the array</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;C&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;1&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">To</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;10</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'assign array element</span><br/><span style="font-size: 8pt; font-family: Courier;">A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">c</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;C</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' print it</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">c</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Next</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'you can add an offset to the index too</span><br/><span style="font-size: 8pt; font-family: Courier;">C&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;0</span><br/><span style="font-size: 8pt; font-family: Courier;">A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">c&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">+</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;1</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;100</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">c&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">+</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;1</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">End</span>
+
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'erzeuge ein Array mit dem Namen "A" mit 10 Elementen vom Typ BYTE</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">10</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'erzeuge eine Integer Variable</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;C&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Integer</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'nun fülle das Array mit Werten</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;C&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;1&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">To</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;10</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp; 'weise dem Array Element einen Wert zu</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp; A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">c</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;C</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp; 'Gebe den Wert auf der Standartschnittstelle aus (normlerweise COM1)</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">&nbsp; Print</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">c</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Next</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Es kann auch einen Offset zum Index mit angegeben werden</span><br/><span style="font-size: 8pt; font-family: Courier;">C&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;0</span><br/><span style="font-size: 8pt; font-family: Courier;">A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">c&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">+</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;1</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;100</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;A</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">c&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">+</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;1</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">End</span>
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,293: Line 1,310:
 
= <span class="f_Header">Strings</span> =
 
= <span class="f_Header">Strings</span> =
  
A string is used to store text. A string must be dimensioned with the length specified.
+
Ein String wird benötigt, um Text zu speichern. Eine String Variable muss unter Angabe der Länge erzeugt (dimensioniert) werden.
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span style="font-family: Arial; font-size: 10pt;">&nbsp;</span>
  
 
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">DIM</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;S&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">as</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">STRING</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">*</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;5</span>
 
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">DIM</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;S&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">as</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">STRING</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">*</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;5</span>
  
<span style="font-family: Arial;">&nbsp;</span>
 
  
Will create a string that can store a text with a maximum length of 5 bytes.
 
  
The space used is 6 bytes because a string is terminated with a null byte.
+
Erzeugt einen String, welcher bis zu 5 Zeichen Text speichern kann. Jedes Zeichen entspricht hierbei einem Byte.
  
<span style="font-family: Arial;">&nbsp;</span>
+
Es werden dafür aber 6 Byte benötigt, da ein String mit einem Byte mit Wert NULL abgeschlossen ist.
  
To assign the string:
+
<span style="font-family: Arial; font-size: 10pt;">&nbsp;</span>
 +
 
 +
Text einer Stringvariablen zuweisen:
  
 
<span style="font-size: 8pt; font-family: Courier;">Ds&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"abcd"</span>
 
<span style="font-size: 8pt; font-family: Courier;">Ds&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"abcd"</span>
Line 1,313: Line 1,330:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
To insert special characters into the string&nbsp;:
+
Spezielle Zeichen einem String zuweisen:&nbsp;
  
 
<span style="font-size: 8pt; font-family: Courier;">s</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"AB{027}cd"</span>
 
<span style="font-size: 8pt; font-family: Courier;">s</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"AB{027}cd"</span>
Line 1,319: Line 1,336:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The {ascii} will insert the ASCII value into the string.
+
<span style="font-family: Arial;">Der Ausdruck&nbsp;</span><span style="font-size: 10pt;">{ascii} fügt das entsprechende ASCII Zeichen in den String ein.</span>
  
<span style="font-family: Arial;">&nbsp;</span>
 
  
The number of digits must be&nbsp;<span style="font-weight: bold;">3</span>.
 
  
s = "{27}" will assign "{27}" to the string instead of escape character 27!
+
<span style="font-family: Arial; font-size: 10pt;">Die ASCII Nummer muss dreistellig angegeben werden (führende Nullen!).</span>
  
&nbsp;
+
s = "{27}" wird "{27}" dem String zuweisen anstelle des ESCAPE Zeichen 27&nbsp;
 +
<div><br/></div>
 +
<br/>ASCII 0 kann nicht in einen String eingefügt werden. Eine Null terminiert den String d.h. zeigt das String Ende an.
  
Because the null byte (ASCII 0) is used to terminate a string, you can not embed a null byte into a string.
 
  
<span style="font-family: Arial;">&nbsp;</span>
 
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,339: Line 1,354:
 
= <span class="f_Header">Casting</span> =
 
= <span class="f_Header">Casting</span> =
  
In BASCOM-AVR when you perform operations on variables they all must be of the same data type.
+
Wenn sie in BASCOM-AVR Operationen durchführen, müssen alle Variablen vom gleichen Datentyp sein.
  
long = long1 * long2 ' for example
+
long = long1 * long2 ' als Beispiel
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The assigned variables data type determines what kind of math is performed.
+
Der zugewiesene Variablen Datentyp bestimmt, welche Art von Berechnung durchgeführt wird.
  
For example when you assign a long, long math will be used.
+
Wenn sie z.B. LONG Typen zuweisen, wird eine Berechnung für LONG Datentypen ausgeführt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
If you try to store the result of a LONG into a byte, only the LSB of the LONG will be stored into the BYTE.
+
Wenn sie versuchen den Inhalt einer LONG Variablen einem Byte zuzuweisen, wird das LSB (niederwerigste Byte) dem Byte zugewiesen.
  
 
Byte = LONG
 
Byte = LONG
Line 1,357: Line 1,372:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When LONG = 256 , it will not fit into a BYTE. The result will be 256 AND 255 = 0.
+
Wenn der LONG einen Wert von 256 enthält, passt dies nicht in ein Byte. Das Ergebnis ist: 256 AND 255 = 0
 +
 
 +
<br/>Binärdarstellung der Maskierung:
 +
 
 +
<span style="font-family:courier new,courier,monospace;">LONG=256 0000 0000 0000 0000 0000 0001 0000 0000</span>
 +
 
 +
<span style="font-family:courier new,courier,monospace;">AND 255 &nbsp;0000 0000 0000 0000 0000 0000 1111 1111</span>
 +
 
 +
<span style="font-family:courier new,courier,monospace;">Ergebnis &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0000 0000 <-- BYTE</span>
 +
 
 +
<br/>Hinweis: 256 AND 255 nennt man Maskieren. 255 ist in binärer Schreibweise 11111111, also 8 BIT auf Wert 1 gesetzt. Im Wert 256 ist keines der unteren 8 BIT auf 1 gesetzt, weshalb bei einem "logischen und" (AND) von 256 und 255 der Wert 0 als Ergebnis steht!
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Of course you are free to use different data types. The correct result is only guaranteed when you are using data types of the same kind or that result always can fit into the target data type.
+
Es steht ihnen frei, unterschiedliche Datentypen zu verwenden. Das richtige Ergebnis ist aber nur garantiert, wenn sie gleiche Datentypen verwenden oder das Ergebnis in den Ergebnis Datentyp passt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,367: Line 1,392:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When you use strings, the same rules apply. But there is one exception:
+
Wenn sie Strings verwenden, gelten die gleichen Regeln bis auf eine Ausnahme:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;b&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">as</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-size: 8pt; font-family: Courier;">b&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;123&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' ok this is normal</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-size: 8pt; font-family: Courier;">b&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"A"</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' b = 65</span>
+
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;b&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">as</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-size: 8pt; font-family: Courier;">b&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;123&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' nichts besonderes, Wert wird einem byte Typ zugewiesen</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-size: 8pt; font-family: Courier;">b&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"A"</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' ASCII von "A" = 65 --> b = 65</span>
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When the target is a byte and the source variable is a string constant denoted by "", the ASCII value will be stored in the byte. This works also for tests&nbsp;:
+
<span style="font-family: Arial;">Wird dem Datentyp BYTE eine Stringkonstante in der Form "A" zugewiesen, so wird der ASCII Wert des Zeichen in das Byte übertragen.</span>
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span style="font-family: Arial;">Dies funktioniert auch bei logischen Vergleichen:</span>
  
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">IF</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;b&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"A"</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">then</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' when b = 65</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">END</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">IF</span>
+
<span style="font-family: Arial; font-size: 10pt;">&nbsp;</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">IF</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;b&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"A"</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">then</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' wenn b = 65</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">END</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">IF</span>
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
This is different compared to QB/VB where you can not assign a string to a byte variable.
+
<span style="font-family: Arial;">Dies ist ein UNterschied zu QB/VB, wo man einen String nicht einem Byte zuweisen kann.</span>
 +
 
 +
 
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 1,391: Line 1,420:
 
= <span class="f_Header">SINGLE CONVERSION</span> =
 
= <span class="f_Header">SINGLE CONVERSION</span> =
  
When you want to convert a SINGLE into a byte, word, integer or long the compiler will automatic convert the values when the source string is of the SINGLE data type.
+
Die Konvertierung eines Single Datentyp in ein Byte, Word, Integer oder Long wird vom Compiler automatisch ausgeführt, sobald der Quelldatentyp vom Typ Single ist.
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span style="font-family: Arial; font-size: 10pt;">&nbsp;</span>
  
 
integer = single
 
integer = single
  
<span style="font-family: Arial;">&nbsp;</span>
 
  
You can also convert a byte, word, integer or long into a SINGLE by assigning this variable to a SINGLE.
 
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span style="font-family: Arial;">Ebenso kann ein Byte, Word, Integer oder Long einem Single Datentyp zugewiesen werden.&nbsp;</span>
 +
 
 +
<span style="font-family: Arial; font-size: 10pt;">&nbsp;</span>
  
 
single = long
 
single = long

Latest revision as of 10:31, 29 August 2013

Label, Schlüsselwörtern, Variablen und Operatoren bestehen aus Zeichen des BASCOM-Zeichensatzes.

Diese wiederum werden zusammengesetzt zu dem, was ein Programm ausmacht.

Dieses Kapitel beschreibt die Zeichen und das Format von BASCOM Programmzeilen.  

Insbesondere beschreibt es:

 

 

die spezielle Bedeutung von Zeichen des Zeichensatzes und besondere Bedeutung einiger Zeichen
das Format einer BASCOM Programmzeile
Zeilen LABELs
Programm Zeilenlänge

 

 

 

Contents

Zeichensatz

Der BASCOM BASIC Zeichensatz besteht alphabetischen Zeichen, numerischen Zeichen und Sonderzeichen. Die alphabetischen Zeichen sind die Zeichen A bis Z in Großschreibung und die Zeichen a bis z in Kleinschreibung.

Die BASCOM numerischen Zeichen sind die Zahlen von 0 bis 9. Die Zeichen A bis H können ebenfalls zur Darstellung hexadezimaler Zahlen verwendet werden. (A-F und &H zur Kennzeichnung einer hexadezimalen Zahl) .

Die folgenden Zeichen haben spezielle Bedeutungen in BASCOM Anweisungen und Ausdrücken: 

 

Character

Name

ENTER

Abschluss einer Engabezeile

 

Leerzeichen ( oder Space)

'

einfaches Anführungszeichen (Apostroph)

*

Stern (Multiplikation Symbol)

+

Plus Zeichen

,

Komma

-

Minus Zeichen

.

Punkt (Dezimalpunkt)

/

Schrägstrich (Slash) (Division Symbol) wird wie \ behandelt

 :

Doppelpunkt

"

doppelte Anführungszeichen

 ;

Semikolon

<

kleiner als

=

Gleichheitszeichen (Zuweisungssymbol or relationaler Operator)

>

größer als

\

Schrägstrich rückwärts (Backslash) (Division Symbol)

^

Exponent

 

 

 

Die BASCOM Programmzeile

BASCOM Programmzeilen haben folgende Syntax:

 

 

[[Line-identifier]] [[Statement]] [[:Statement]] ... [[Comment]]

 

 

Sprungmarken (Label)

BASCOM unterstützt alphanumerische Sprungmarken (Label).

 

 

Ein Label besteht aus 1 bis 32 Buchstaben oder Zahlen. Sie beginnen mit einem Buchstaben und enden mit einem Doppelpunkt.

BASCOM Schlüsselwörter sind nicht erlaubt. (z.B. print:)

 

Beispiele zu gültigen Label:

 

Alpha:

ScreenSUB:

Test3A:

 

Groß- Kleinschreibung wird nicht unterschieden. Folgende Beispiele zeigen unterschiedliche Schreibweisen, stehen aber für ein und dasselbe Label.

 

alpha:

Alpha:

ALPHA:

 

 

Label können an einer beliebigen Stelle in einer Zeile beginnen, so lange sich links vom Label lediglich Leerzeichen befinden.

Leerzeichen innerhalb des Label Namen und zwischen Label Name und dem abschließenden Doppelpunkt sind nicht erlaubt.

In einer Zeile darf sich nur ein Label befinden. In einer Zeile mit einem Label darf sich nur dieses Label befinden, also keine weiteren Anweisungen oder Instruktionen oder Ausdrücke. Ein Label ist der einzige Ausdruck in einer Zeile. (z.B. NICHT Label: print hier muss die Print Anweisung in der folgenden Zeile stehen)

 

 

BASCOM Anweisungen (Befehle)

Eine BASCOM Anweisung ist entweder "ausführbar" oder "nicht ausführbar".

Eine ausführbare Anweisung (Befehl) führt Schritte in der Programmlogik aus. Ein Beispiel eines ausführbare Befehl ist "Print". Hier wird der Befehl zur Ausgabe von Daten gegeben.

Nicht ausführbare Anweisungen dienen z.B. der Speicherzuweisung, Deklaration oder Definition des Types von Variablen.

 

Im folgenden Beispiele für "nicht ausführbare Anweisungen"

REM (Startet eine Kommentierung)
DIM (legt den Typ einer Variablen fest)

 

 

Eine Kommentierung (Comment) ist eine "nicht ausführbare Anweisung" und dient dazu Schritte im Programm zu beschreiben oder verdeutlichen. Verwenden sie gerade zu Beginn viele Kommentierungen, damit sie sich selbst den Sinn und Zweck von Befehlszeilen verdeutlichen.

Eine Kommentierung wird mit dem Befehl (REM) oder einem einfachen Anführungszeichen (') eingeleitet. Solch eine Kommentierung hat lediglich in der betreffenden Zeile Gültigkeit. (siehe auch Blockkommentierung)

Die folgenden Zeilen bewirken das gleiche:

 

PRINT " Quantity remaining" : REM Print report label.
PRINT " Quantity remaining" ' Print report label.

 

Es können mehrere BASCOM Befehle in einer Zeile stehen, diese müssen aber mit einem Doppelpunkt von einander getrennt sein, wie nachfolgendes Beispiel zeigt.

 

FOR I = 1 TO 5 : PRINT " Gday, mate." : NEXT I

 

 

BASCOM Zeilenlänge

Wenn sie den BASCOM eigenen Editor benutzen, ist die Länge einer Zeile nicht beschränkt. Zur besseren Übersicht wird aber dazu geraten, die Zeile auf 80 Zeichen zu beschränken.

 

 

Datentypen

Jede BASCOM Variable ist einem Datentyp zugeordnet. Hiervon hängt ab, welcher Wert in einer Variablen gespeichert werden kann. Der nächste Abschnitt beschreibt die elementaren Datentypen.

 

 

 

Elementare Datentypen

 

Bit (1/8 Byte). Ein BIT kann nur genau eine Informationseinheit speichern. Dies ist entweder eine 0 oder eine 1. Eine Gruppe von 8 Bit nennt man 1 BYTE.
Byte (1 Byte).  Bytes werden als "unsigned" (vorzeichenlos) 8-Bit Werte gespeichert. Ein Byte kann eine natürliche Zahl im Bereich von 0 bis 255 darstellen. (nicht negative ganze Zahl)
Integer (zwei Byte). Integer wird als "signed" (vorzeichenbehaftet) 16-Bit binäre Zahl gespeichert. Der darstellbare Zahlenraum liegt hierbei von -32.768 bis +32.767
Word (zwei Byte). WORD wird als "unsigned" (vorzeichenlos) 16-Bit Werte gespeichert. Ein Word kann eine natürliche Zahl im Bereich von 0 bis 65535 darstellen.
Dword (vier Byte). DWORD wird als "unsigned" (vorzeichenlos) 32-Bit Werte gespeichert. Ein DWord kann eine natürliche Zahl im Bereich von 0 bis 4294967295 darstellen.
Long (vier Byte). Integer wird als "signed" (vorzeichenbehaftet) 32-Bit binäre Zahl gespeichert. Der darstellbare Zahlenraum liegt hierbei von -2147483648 bis 2147483647.
Single (vier Byte). Singles wird als "signed" (vorzeichenbehaftet) 32-Bit binäre Zahl gespeichert. Der darstellbare Zahlenraum liegt hierbei von 1.5 x 10^–45 bis 3.4 x 10^38
Double (acht Byte). Double wird als "signed" (vorzeichenbehaftet) 64-Bit binäre Zahl gespeichert.Der darstellbare Zahlenraum liegt hierbei von 5.0 x 10^–324 bis 1.7 x 10^308
String (bis zu 254 Byte). String (Zeichenkette) wird als Folge von Bytes gespeichert mit abschließenden Byte mit Wert 0. Ein String mit einer Länge von 10 Zeichen belegt 11 Byte Speicher.

 

Variablen können intern (Standard), extern oder im EEPROM gespeichert werden.

 

 

Variablen

Eine Variable ist ein Name, welcher auf ein Objekt in einem Speicherbereich zeigt

Einer numerischen Variable kann, ihrer Definition entsprechend, nur eine Zahl zugewiesen werden.

Im Folgenden ein paar Beispiele von Variablen Zuweisungen:

 

Einen konstanten Wert zuweisen:

A = 5

C = 1.1

 

Den Wert einer anderen Variable einer Variable zuweisen:

abc = def

k = g

 

Den Wert durch die Kombination von anderen Variablen, Konstanten und Operatoren erhalten: Temp = a + 5

Temp = C + 5

 

Den Wert durch Aufruf einer Funktion erhalten:

Temp = Asc(S)

 

 

Variablen Namen

Ein BASCOM Variablen Name kann bis zu 32 Zeichen lang sein.

Der Name darf Buchstaben und Zahlen enthalten.

Das erste Zeichen des Namen muss ein Buchstabe sein

 

Ein Variablenname darf kein reserviertes Wort sein, aber kann es beinhalten.

Die Anweisung im folgenden Beispiel ist nicht erlaubt, da AND ein reserviertes Wort ist:

 

AND = 8

 

Die Anweisung im folgenden Beispiel ist gültig:

 

ToAND = 8

 

 

Reservierte Wörter umfassen alle BASCOM Befehle, Ausdrücke, Funktion, interne Register und Operatoren.

(siehe BASCOM Reservierte Wörter, für eine Liste mit allen reservierten Wörtern).

 

Hexadezimal Zahlen werden mit &H angegeben. Binäre Zahlen werden mit &B angegeben.

a = &HA , a = &B1010 und a = 10 weist der Variablen das Gleiche zu.

 

Vor der Benutzung einer Variable, muss diese dem Compiler durch eine  DIM  Anweisung bekannt gemacht werden.

Dim b1 As Bit, I as Integer, k as Byte , s As String * 10

 

Bei dem Variablentyp STRING muss zusätzlich die Länge des String angegeben werden

 

 

Ebenfalls möglich: DEFINTDEFBITDEFBYTE ,DEFWORD ,DEFLNG or DEFSNG.

 

Beispiel: DEFINT c teilt dem Compiler mit, dass alle undefinierten Variablen welche mit dem Zeichen "c" anfangen, vom Typ INTEGER sind.

 

 

Ausdrücke und Operatoren

Dieses Kapitel beschreibt, wie man Ausdrücke und Operatoren in BASCOM anwendet.

 

Bei jeder Berechnung werden Ausdrücke und Operatoren verwendet.

 

Dieses Kapitel beschreibt, wie Ausdrücke gebildet werden und schließt mit der Beschreibung der Art von Operatoren:

 

Arithmetische Operatoren, werden für Berechnungen verwendet.
Verhältnis (Relational) Operatoren, Vergleich von numerischen oder auch String Variablen.
Logische Operatoren, Testen von Bedingungen oder Veränderung von Bits.
Funktions Operatoren, zur Ergänzung der einfachen Operatoren.

 

 

 


Ein Ausdruck kann eine numerische Konstante, eine Variable oder ein einzelner Wert durch die Kombination von Konstanten, Variablen und andere Ausdrücken mit Operatoren sein.

 

Operatoren führen mathematische oder logischen Operationen an Werten durch.

Die von BASCOM zur Verfügung stehenden Operatoren sind in vier Gruppen einzuordnen:

 

1. Arithmetisch

2. Verhältnis (Relational)

3. Logisch

4. Funktionen

 

 

Arithmetic

Arithmetische Operatoren sind +, - , * , \, / und ^.

 

Integer

Integer Division wird durch den Schrägstrich rückwärts (\)(Backslash) dargestellt.

Beispiel: Z = X \ Y

 

Modulo Arithmetik

Modulo Arithmetik wird mit MOD durchgeführt.

Eine Modulo Arithmetik ergibt den Teilungsrest einer ganzzahligen Division.

 

Beispiel: X = 10 \ 4 : Teilungsrest= 10 MOD 4

 

Overflow und "Division by zero" (Überlauf und Teilung durch 0)

"Division by zero" oder Teilung durch 0, erzeugt einen Fehler.

Hierbei findet keine Fehlerausgabe statt, sie müssen selbst dafür Sorge tragen, dass dies nicht eintreten kann.

 

 

Relationale Operatoren (Verhältnis Operatoren)

Relationale Operatoren werden verwendet, um zwei Werte miteinander zu vergleichen. Die Operatoren sind in folgender Tabelle aufgelistet.

Das Ergebnis kann verwendet werden, um den Programmablauf zu steuern.

 

Operator

Vergleich

Ausdruck

=

gleich

X = Y

<>

unterschiedlich

X <> Y

<

kleiner als

X < Y

>

größer als

X > Y

<=

kleiner oder gleich

X <= Y

>=

größer oder gleich

X >= Y

 

 

Logische Operatoren

Logische Operatoren prüfen Bits, manipulieren Bits oder sind boolsche Operatoren.

Es gibt in BASCOM vier logische Operatoren :

 

Operator

Bedeutung

NOT

Logisches Komplementär

AND

logisches UND

OR

logisches ODER

XOR

Exclusiv ODER (Exclusive or)

 

Es ist möglich logische Operatoren zu verwenden, um Bytes auf Bitmuster zu testen.

Zum Beispiel kann der AND Operator dazu benutzt werden, alle bis auf ein BIT auszumaskieren. Der OR Operator kann dazu benutzt werden, um zwei Bytes zu einem neuen Wert zusammen zu fassen.

 

 

Beispiel:

= 63 And 19
PRINT A
= 10 Or 9
PRINT A

 

 

Ausgabe:

19

11

 

 

 

Fließkomma SINGLE (4 BYTE)

SINGLE Zahlen entsprechen dem IEEE Fließkomma Standard.

Ein Acht-Bit-Exponent und 24 Bit Mantisse werden unterstützt.

Bei Verwendung von vier Byte ergibt sich folgendes Ergebnis:

 

 

31 30________23 22______________________________0

 

s Exponent Mantisse

 

 

Der Exponent wird durch 128 vorgeladen. Oberhalb 128 sind positive Exponenten, unterhalb sind Negative. Das Vorzeichenbit für positive Zahlen ist 0 und 1 für Negative. Die Mantisse wird in einem versteckten Bit in normalisiertem Format gespeichert, so dass 24 Bits Präzision erreicht werden.

 

Alle mathematischen Operationen werden durch SINGLE unterstützt

Sie können einen SINGLE zu einem INTEGER oder WORD konvertieren oder anders herum.

 

Dim I as Integer, S as Single

 

S = 100.1 'Ein SINGLE zuweisen

I = S  'Konvertiert den SINGLE zu einem WORD

 

 

Hier ein Auszug aus der "Microsoft knowledge base" über FP (Fließkomma):

 

Floating-point mathematics is a complex topic that confuses many programmers. The tutorial below should help you recognize programming situations where floating-point errors are likely to occur and how to avoid them. It should also allow you to recognize cases that are caused by inherent floating-point math limitations as opposed to actual compiler bugs.

 

 

 

Dezimale und binäre Zahlensysteme

Normalerweise rechnen wir im 10er Zahlensystem, dem Dezimalsystem.

Die Basis 10 ist dabei völlig willkürlich gewählt. Der einzige Grund mit der Basis von 10 zu rechnen ist, das Menschen mit ihren 10 Fingern arbeiteten um Berechnungen durchzuführen.


Zur Verdeutlichung:

Rechnen in einem Zahlensystem mit der Basis 10 bedeutet, dass ein Übertrag zur nächsten Stelle nach der Verwendung der 10 möglichen Zeichen stattfindet. Der Zeichenvorrat im Dezimalsystem ist also 10. (0,1,2,3,4,5,6,7,8,9) Die Wertigkeit der Stellen ist demnach: 1, 10, 100, 1000 und so weiter. Ein negativer Exponent, z.B. 10^-1 stellt den Nachkommawert dar. 10^-1 ist hiernach 1/10, 10^-2 = 1/100, 10^-3 = 1/1000 usw.


Die Zahl 101 im Dezimalsystem drückt folgendes aus: (1 * 100) + (0 * 10) + (1 * 1) = 101 (dezimal)


Im Binärsystem (Zweierzahlensystem) ist der Zeichenvorrat genau zwei Zeichen groß: 0 und 1. Nach der Verwendung der 1, erfolgt bereits ein Übertrag zur nächsten Stelle. Hier ist die Wertigkeit der Stellen: 1, 2, 4, 8, 16 und so weiter. Ein negativer Exponent, z.B. 2^-1 stellt den Nachkommawert dar. 2^-1 ist hiernach 1/2, 10^-2 = 1/4, 10^-2 = 1/8 usw.


Die Zahl 101 im Binärsystem drückt folgendes aus: (1 * 4) + (0 * 2) + (1 * 1) = 101 (binär) = 5 (dezimal)

 

 

Die dezimale Darstellung der Zahl 532,25 sieht wie folgt aus:

 

(5 * 10^2) + (3 * 10^1) + (2 * 10^0) + (2 * 10^-1) + (5 * 10^-2)

 

500 + 30 + 2 + 2/10 + 5/100

_________

 

= 532.25

 

 

Im binären Zahlensystem ist die Basis 2, im Gegensatz zum dezimalen, wo die Basis 10 lautet. Darstellung der Zahl 101,01 im Binärsystem:

(1 * 2^2) + (0 * 2^1) + (1 * 2^0) + (0 * 2^-1) + (1 * 2^-2)

4 + 0 + 1 + 0 + 1/4

_________

= 5.25 Decimal

 

 

Wie INTEGER in Rechnern dargestellt werden

 


Da es keinen Bruchteil (Nachkommawert) bei INTEGER gibt, ist die Darstellung sehr viel einfacher als für Fließkommazahlen. Es handelt sich also um ganze Zahlen. Normalerweise sind INTEGER in Rechnern zwei BYTE (16 BIT) groß. Das höchstwertige BIT zeigt das Vorzeichen an (positive oder negative Ganzzahl). Neben einem INTEGER gibt es auch einen LONGINTEGER, welcher vier Byte umfasst.

 

Positive Zahlenwerte sind einfache binäre Zahlen. Zum Beispiel:

 

 

1 dezimal = 1 binär

2 dezimal = 10 binär

22 dezimal = 10110 binär, usw.

 

Negative INTEGER werden durch das Zweierkomplement dargestellt. Um das Zweierkomplement einer negativen Zahl zu erhalten, wird die Zahl zunächst binär als positive Ganzzahl im INTEGER dargestellt. Danach werden alle BITs des INTEGER umgekehrt. Als letzten Schritt wird der Wert 1 addiert.


 

 

4 dezimal = 0000 0000 0000 0100

 

1111 1111 1111 1011 Alle Bits umkehren (Flip the Bits)

 

-4 = 1111 1111 1111 1100 Zahl 1 addieren (Add 1)

 

 

Bei der Addition zweier Zahlen im Zweier-Komplement kommt immer das richtige Ergebnis heraus -  

auch wenn eine oder beide Zahlen negative Zahlen darstellen.

 

 

Fließkomma Zahlenfehler

Jeder dezimal INTEGER Wert (rationale Zahl!) kann exakt Binär dargestellt werden. Dies gilt nicht für Fließkomma Zahlen (irrationale Zahl)! Eine irrationale Zahl ist eine reelle Zahl, die keine rationale Zahl ist. Eine irrationale Zahl ist dadurch gekennzeichnet, dass sie kein Verhältnis von ganzen Zahlen ist. Eine reelle Zahl heißt irrational, wenn sie nicht als Bruch zweier ganzer Zahlen dargestellt werden kann. Eine bekannte irrationale Zahl ist PI.


Merke: Jede irrationale Zahl im Dezimalsystem ist in jedem anderen Zahlensystem irrational!

 

Für das Binärsystem im Besonderen gilt: Jede Bruchteil einer ganzen Zahl ("Nachkommawert"), in der Form p/q (wobei q eine ganzzahlige Potenz von 2 ist), kann exakt dargestellt werden mit einer endlichen Anzahl von BIT.


 

Auch Dezimalbrüche wie 1/10000 oder 0,0001 können Binär nicht exakt dargestellt werden. Hierbei liegt die Periode bei 104 BIT (periodische Wiederkehr von Teilungsbrüchen).

 

 

Dies erklärt, warum bei diesem einfachen Beispiel...

 

SUM = 0
FOR I% = 1 TO 10000
 SUM = SUM + 0.0001
NEXT I%
PRINT SUM ' Theoretically = 1.0.

 

 

1.000054 ausgegeben wird. Ein kleiner Fehler macht sich bei der Darstellung der Summierung von 0.0001 bemerkbar!

 

 

Aus diesem Grund sollten sie sehr vorsichtig mit dem Vergleich reeller Zahlen umgehen. Das folgende Beispiel zeigt einen häufig begangenen Programmierfehler:

 

 

item1# = 69.82#

item2# = 69.20# + 0.62#

IF item1# = item2# then print "Equality!"

 

 

Dies wird NICHT "Equality!" (GLEICH) AUSGEBEN, weil 69.82 im Binärsystem nicht exakt dargestellt werden kann. Der Wert der binären Berechnung unterscheidet sich also geringfügig von dem direkt zugewiesenen Wert. In der Praxis sollten sie diesen Vergleich mit einer gewissen Toleranz ausführen.

 

 

 

Allgemeine Fließkommazahlen Konzepte

Es ist sehr wichtig zu verstehen, dass jedes Fließkommazahlen System nur eine endliche Anzahl von Fließkommazahlen exakt darstellen kann. Alle anderen Werte müssen zum nächstmöglichen darstellbaren Wert angenähert werden. Der IEEE Standard definiert die Methode zum nächstmöglichen darstellbaren Wert. BASCOM unterstützt diesen Standard und rundet nach den IEEE Spezifikationen.

 

Denken sie bitte auch daran, dass Zahlendarstellungen nach dem IEEE Standard eine große Streuung beinhalten können. Es gibt eine hohe Genauigkeit im Bereich zwischen 1,0 und -1,0, aber je näher sie sich der 0 oder unendlich großen Zahlen annähern, je ungenauer wird das Ergebnis sein.

 

Der Vorteil des IEEE Standard, welcher für technische Berechnungen konzipiert wurde, ist die Genauigkeit zu maximieren (so nah als möglich dem richtigen Ergebnis zu sein). Präzision ist hier gleichbedeutend der Anzahl der darstellbaren Stellen. Der IEEE Standard empfiehlt hier eine Balance zwischen den BITs für den Exponent und den BITs für den Nachkommaanteil zu finden, um sowohl Genauigkeit als auch Präzision in akzeptablen Grenzen zu halten.

 

Erläuterung zur Exponentialdarstellung:

Praktisch alle Mikroprozessoren beherrschen zunächst nur den Umgang mit ganzen Zahlen, den sogenannten Integer-Zahlen.

Bei der Speicherung einer Fließkommazahl im binären System, muss das Komma zusammen mit der eigentlichen Zahl gespeichert werden. Das Komma ist keine feststehende Position innerhalb einer beliebigen Fließkommazahl. Beispiel hierzu: 0,12 1234,5 Die eigentliche Zahl einer Fließkommazahl ist die reine Ziffernfolge der Zahl, ohne das Komma. Man nennt sie auch Mantisse. Beispiel: 123,45 --> Mantisse 12345 Die Kommastellung zur Mantisse relativ zur Mantisse wird durch einen Exponenten angegeben. Bei negativen Exponenten wird das Komma nach links verschoben, positive Exponenten verschieben das Komma nach rechts.


Merke: Eine Zahl mit Komma ist also durch zwei ganze Zahlen dargestellt.


Einen EURO Betrag von 12,34 kann man also durch die Mantisse 1234 und den Exponenten -2 abspeichern. Bei diesem Beispiel würden wir aber bei Exponent=0 implizieren, dass das Komma hinter der letzten Ziffer (also am rechten Ende) der Mantisse stehen würde.


In der Praxis verwendet man allerdings eine "normalisierte Darstellung". Dabei steht das Komma hinter der ersten Stelle, welche ungleich 0 ist. Diese Darstellung ist als "wissenschaftliche Darstellung" bekannt und wird von jedem Taschenrechner unterstützt.


Unser obiges Beispiel in wissenschaftlicher Darstellung sieht wie folgt aus: aus 12,34 wird die Mantisse 1,234 und der Exponent 1 (also Komma um eine Stelle nach rechts schieben)

Diese Betrachtung gilt für die Normalisierung einer Dezimalzahl mit dem Zeichenvorrat von 0 bis 9. Demnach könnte die Mantisse einer Dezimalzahl also an der ersten Stelle eine Zahl zwischen 0 und 9 sein.


Anders ist es bei der Darstellung dieser Zahl im binären Zahlensystem. Hier haben wir nur zwei Zeichen zur Verfügung. Nachdem führende Nullen in der Binärzahl keine Bedeutung haben, ist die erste Stelle einer Zahl im Binärsystem bei wissenschaftlicher Darstellung also immer eine 1. Dieser 1 folgt das Komma und weitere Ziffern. Die Mantisse kann nun in zwei Teile zerlegt werden:

- den Vorkommateil (also die führende 1)

- den Nachkommateil (engl. "fraction" oder in deutsch "Bruchteil") auch bezeichnet als Binärbruch


Die Schreibweise „1e9" ist eine Abkürzung für 1 x 10^9, also für den Wert 1 000 000 000, eine Eins mit neun Nullen. Man nennt dies die Exponentialdarstellung. Im Binärsystem lautet die Exponentialdarstellung beispielsweise: „1e101" (ist eine Abkürzung für 1 x 2^5). Das Zeichen „e" wird also immer gegen die Basis des jeweiligen Zahlensystems ausgetauscht (10 für Dezimalsystem, 2 für Binärsystem, 16 für Hexadezimalsystem). Die Zahl 100,0 entspricht 1,0 x 10^2 - eine Verschiebung des Kommas nach links entspricht einer Erhöhung des Exponenten. Die Zahl 0,001 entspricht 1,0 x 10^-3 - eine Verschiebung des Kommas nach rechts entspricht einer Verringerung des Exponenten.

 

IEEE Details

Fließkommazahlen werden in folgender Form dargestellt, wobei

[exponent] der binäre Exponent ist:

 

X = Fraction * 2^(exponent - bias)

 

[Fraction] ist der normalisierte Teil des Bruchteil der Zahl. Normalisiert, weil hier der Exponent derart angepasst wird, dass führende Zahl immer 1 ist. Da diese immer 1 ist, muss diese nicht gespeichert werden und man erlangt dadurch eine Stelle mehr für die Präzision. Da eine binäre Zahl nur aus 0 und 1 besteht, kann man den Exponenten so lange ändern, bis eine 1 vor dem Komma steht.

 

[bias] Der Vorgabewert (BIAS) wird verwendet um zu vermeiden, dass negative Exponenten gespeichert werden müssen.

 

Der BIAS Wert für einfache Präzision (single precision numbers) ist 127 (dez) und 1023 (dez) für doppelte Genauigkeit (double-precision numbers)

 

Binäre Werte, bei denen alle Bit 0 oder 1 sind, sind speziellen Fällen vorbehalten. Es bestehen noch weitere spezielle Fälle, welche verschiedene Fehlerzustände darstellen.

 

 

Single-Precision Beispiele

2 = 1 * 2^1 = 0100 0000 0000 0000 ... 0000 0000 = 4000 0000 hex

Beachte, dass das Vorzeichenbit 0 ist und der Exponent 128, oder

 

100 0000 0 in Binärcode, welcher 127 + 1 ist. Die gespeicherte Mantisse ist (1.)

000 0000 ... 0000 0000, welche eine implizierte führende 1 hat. Die aktuelle Mantisse lautet also 1

 

 

-2 = -1 * 2^1 = 1100 0000 0000 0000 ... 0000 0000 = C000 0000 hex

Das Gleiche wie +2, außer das das Vorzeichenbit gesetzt wurde. Dies gilt für alle IEEE-Format Gleitkommazahlen.

 

4 = 1 * 2^2 = 0100 0000 1000 0000 ... 0000 0000 = 4080 0000 hex

Gleiche Mantisse, aber Exponent durch 1 erhöht (BIAS Wert ist 129 oder 100 0000 1 in Binärcode)

 

6 = 1.5 * 2^2 = 0100 0000 1100 0000 ... 0000 0000 = 40C0 0000 hex

Gleicher Exponent, die Mantisse ist um die Hälfe größer -- es ist

 

(1.) 100 0000 ... 0000 0000, was, weil es sich um einen Binärbruch handelt, 1-1/2 (in Worten Ein und Einhalb)(die Werte eines Binärbruches sind 1/2, 1/4, 1/8, etc.).

 

1 = 1 * 2^0 = 0011 1111 1000 0000 ... 0000 0000 = 3F80 0000 hex

Der gleiche Exponent wie bei anderen Potenzen von 2, Mantisse ist eins weniger als 2 von 127 in Binärcode 011 1111 1

 

.75 = 1.5 * 2^-1 = 0011 1111 0100 0000 ... 0000 0000 = 3F40 0000 hex

 

Der vorgeladene ("biased") Exponent ist 126, im Binärcode 011 1111 0, und die Mantisse ist (1.) 100 0000 ... 0000 0000, was 1-1/2 entspricht.

 

 

2.5 = 1.25 * 2^1 = 0100 0000 0010 0000 ... 0000 0000 = 4020 0000 hex

Exakt das Gleiche wie 2, lediglich das BIT, welches 1/4 darstellt, ist in der Mantisse gesetzt.

 

 

0.1 = 1.6 * 2^-4 = 0011 1101 1100 1100 ... 1100 1101 = 3DCC CCCD hex

 

1/10 ist ein sich immer wiederholender Nachkommaanteil im binären System (periodischer Teilungsrest). Die Mantisse liegt nahe dem Wert von 1,6 und der Exponent besagt, dass 1,6 durch 16 geteilt werden soll (es ist 011 1101 1 in binären Darstellung, also 123 in Dezimalzahl). Der tatsächliche Exponent ist 123 - 127 = -4 was bedeutet, dass der Faktor für die Multiplikation 2^-4 = 1/16 beträgt. Beachten Sie, dass die gespeicherte Mantisse in dem letzten Bit gerundet ist. Dies ist ein Versuch eine nicht darstellbare Zahl so genau wie möglich darzustellen. (Der Grund, dass 1/10 und 1/100 binärer nicht exakt dargestellt werden können ist ähnlich dem, dass 1/3 nicht exakt im dezimalen System dargestellt werden kann. Dies ergibt eben eine unendliche Periode von 3 --> 0,3333...)


 

 

0 = 1.0 * 2^-128 = Alles 0 -- ein spezieller Fall.

 

 

Andere häufige Fließkommazahlen Fehler

Im folgenden sind häufige Fließkommazahl Fehler beschrieben:

 

1. Rundungsfehler

Dieser Fehler ergibt sich, wenn nicht alle Bits einer binären Zahl in einer Berechnung benutzt werden.

Beispiel: Addiere 0.0001 bis 0.9900 (einfache Genauigkeit, "Single Precision")

Dezimal 0.0001 wird dargestellt als:

(1.)10100011011011100010111 * 2^(-14+Bias) (13 führende Nullen in Binärzahl!)

 

 

0.9900 wird dargestellt als:

(1.)11111010111000010100011 * 2^(-1+Bias)

 

Um nun diese Zahlen zu addieren, muss das binär Trennzeichen (Komma der Nachkommastellen) ausgerichtet werden. Eine Normalisierung ist dafür nicht notwendig. Hier ist die resultierende Addition:

 

.000000000000011010001101 * 2^0 <- Nur 11 von 23 Bits erhalten

+.111111010111000010100011 * 2^0

________________________________

.111111010111011100110000 * 2^0

 

 

Dies wird als Rundungsfehler bezeichnet. Einige Rechner runden, wenn BITs zum Zweck der Addition geschoben werden, andere beschneiden das Ergebnis einfach. Es ist sehr wichtig Rundungsfehler zu beachten, wenn sie zwei sehr unterschiedliche Werte addieren oder multiplizieren.

 

 

2. Subtrahieren von zwei annähernd gleichen Werten

 

.1235

-.1234

_____

.0001

 

Dies wird normalisiert werden. Beachten sie, dass das Ergebnis nur eine signifikante Ziffer hat obwohl die ursprünglichen Zahlen jeweils vier signifikante Stellen hatten.

 

 

3. Überlauf und Unterlauf

Dies passiert, wenn das Ergebnis einer Berechnung zu groß oder auch zu klein wird, um es im jeweiligen Datentyp darzustellen.

 

 

4. Quantisierungsfehler

Ist die Differenz aus der gestuften Näherung und dem (unverfälschten) Originalwert.

Tritt auf bei irrationale Zahlen, welche binär nicht dargestellt werden können.

 

 

 

Runden

Wenn ein Long einem Single zugewiesen wird, wird die Zahl nach den Regeln des IEEE-Komitee abgerundet.

 

Zur Erläuterung: 1,500000 ist exakt die Mitte zwischen 1,000000 und 2,000000. Wird x,500000 immer aufgerundet, so ist der Trend aller Rundungen höher, als der Durchschnitt aller tatsächlichen Werte. Die Regel besagt aus diesem Grund abwechselnd auf- und abzurunden, wenn der Wert hinter dem LSB exakt ,500000000 ist.

 

Die Regel ist: Runde ,500000000000 zur nächsten ganzen Zahl auf. Bei der folgenden ,500000000000 wird nichts unternommen, der Bruchteil verfällt also.

 

Da dies im Wechsel stattfindet ist die Summe der Fehler 0 (NULL).

 

Sie können die standard IEEE Rundungsmethode ändern, indem sie eine Library einbinden: $LIB LONG2FLOAT.LBX. Diese rundet immer zur nächsten Zahl auf. Diese Methode wurde bis zur Compilerversion 1.11.7.4 verwendet.

 

 

 

Double

Ein DOUBLE ist im Grunde das Gleiche wie ein SINGLE bis auf die Tatsache, dass ein DOUBLE 8 Byte anstelle von 4 Byte beim SINGLE verwendet. Der Exponent ist 11 BIT groß, damit verbleiben 52 BIT für die Mantisse.

 

 

Arrays

Ein Array ist eine Gruppe von fortlaufend indizierten Elementen gleichen Typs. Jedes Element eines Arrays hat eine eindeutige Index Nummer, die es identifiziert. Änderungen eines Elementes eines Array haben keinen Effekt auf die anderen Elemente.

 

Der Index muss eine numerische Konstante, ein Byte, ein Integer, ein Word oder ein Long sein.

Die maximale Anzahl Elemente in einem Array beträgt 65535. Bei Xmega Typen mit großem Speicherbereich beträgt sie 8MB.

Der Index von Arrays ist 1 basierend d.h. das erste Element eines Array hat den Index 1.

Dies kann mit CONFIG BASE=0 geändert werden zu einem 0 basierenden Index. Der Index des erste Elementes des Array ist dann 0.

 

Array Elemente können überall dort verwendet werden, wo auch "normale" Variablen verwendet werden können.

 

Sie können auch einen Offset zu einem Index addieren. Dies kann benutzt werden, um zweidimensionale Arrays darzustellen.

row_index = row  :  shift row_index, left,4

value = parameter_array(column+row_index)

 

 

 

Beispiel ARRAY

 

'erzeuge ein Array mit dem Namen "A" mit 10 Elementen vom Typ BYTE
Dim A(10) As Byte
'erzeuge eine Integer Variable
Dim C As Integer
'nun fülle das Array mit Werten
For C = 1 To 10
  'weise dem Array Element einen Wert zu
  A(c)= C
  'Gebe den Wert auf der Standartschnittstelle aus (normlerweise COM1)
  Print A(c)
Next
'Es kann auch einen Offset zum Index mit angegeben werden
= 0
A(+ 1)= 100
Print A(+ 1)
End

 

 

Strings

Ein String wird benötigt, um Text zu speichern. Eine String Variable muss unter Angabe der Länge erzeugt (dimensioniert) werden.

 

DIM S as STRING * 5


Erzeugt einen String, welcher bis zu 5 Zeichen Text speichern kann. Jedes Zeichen entspricht hierbei einem Byte.

Es werden dafür aber 6 Byte benötigt, da ein String mit einem Byte mit Wert NULL abgeschlossen ist.

 

Text einer Stringvariablen zuweisen:

Ds = "abcd"

 

Spezielle Zeichen einem String zuweisen: 

s= "AB{027}cd"

 

Der Ausdruck {ascii} fügt das entsprechende ASCII Zeichen in den String ein.


Die ASCII Nummer muss dreistellig angegeben werden (führende Nullen!).

s = "{27}" wird "{27}" dem String zuweisen anstelle des ESCAPE Zeichen 27 



ASCII 0 kann nicht in einen String eingefügt werden. Eine Null terminiert den String d.h. zeigt das String Ende an.


 

 

Casting

Wenn sie in BASCOM-AVR Operationen durchführen, müssen alle Variablen vom gleichen Datentyp sein.

long = long1 * long2 ' als Beispiel

 

Der zugewiesene Variablen Datentyp bestimmt, welche Art von Berechnung durchgeführt wird.

Wenn sie z.B. LONG Typen zuweisen, wird eine Berechnung für LONG Datentypen ausgeführt.

 

Wenn sie versuchen den Inhalt einer LONG Variablen einem Byte zuzuweisen, wird das LSB (niederwerigste Byte) dem Byte zugewiesen.

Byte = LONG

 

Wenn der LONG einen Wert von 256 enthält, passt dies nicht in ein Byte. Das Ergebnis ist: 256 AND 255 = 0


Binärdarstellung der Maskierung:

LONG=256 0000 0000 0000 0000 0000 0001 0000 0000

AND 255  0000 0000 0000 0000 0000 0000 1111 1111

Ergebnis                               0000 0000 <-- BYTE


Hinweis: 256 AND 255 nennt man Maskieren. 255 ist in binärer Schreibweise 11111111, also 8 BIT auf Wert 1 gesetzt. Im Wert 256 ist keines der unteren 8 BIT auf 1 gesetzt, weshalb bei einem "logischen und" (AND) von 256 und 255 der Wert 0 als Ergebnis steht!

 

Es steht ihnen frei, unterschiedliche Datentypen zu verwenden. Das richtige Ergebnis ist aber nur garantiert, wenn sie gleiche Datentypen verwenden oder das Ergebnis in den Ergebnis Datentyp passt.

 

 

Wenn sie Strings verwenden, gelten die gleichen Regeln bis auf eine Ausnahme:

 

Dim b as Byte
 
= 123 ' nichts besonderes, Wert wird einem byte Typ zugewiesen
 
= "A" ' ASCII von "A" = 65 --> b = 65

 

Wird dem Datentyp BYTE eine Stringkonstante in der Form "A" zugewiesen, so wird der ASCII Wert des Zeichen in das Byte übertragen.

Dies funktioniert auch bei logischen Vergleichen:

 

IF b = "A" then ' wenn b = 65
 
END IF

 

Dies ist ein UNterschied zu QB/VB, wo man einen String nicht einem Byte zuweisen kann.


 

 

SINGLE CONVERSION

Die Konvertierung eines Single Datentyp in ein Byte, Word, Integer oder Long wird vom Compiler automatisch ausgeführt, sobald der Quelldatentyp vom Typ Single ist.

 

integer = single


Ebenso kann ein Byte, Word, Integer oder Long einem Single Datentyp zugewiesen werden. 

 

single = long



Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language