Short-Circuit-Evaluation

Short-Circuit-Evaluation

Kurzschlussauswertung (Short Circuit Evaluation) ist ein Begriff aus der Informatik und betrifft das Auswerten von booleschen Ausdrücken. Dabei wird das Auswerten eines Ausdrucks abgebrochen, wenn das Ergebnis bereits feststeht.

Beispiel:

C = A UND B

Der Ausdruck wird von links nach rechts ausgewertet. Falls dabei A unwahr (false) ist, steht also fest, dass C auf jeden Fall auch unwahr ist, da A und B wahr sein müssen damit die Bedingung erfüllt ist.

Verschiedene Programmiersprachen verwenden die Kurzschlussauswertung um die Ausführgeschwindigkeit zu optimieren.

Ein Beispiel verdeutlicht das Verhalten:

A = 0
B = 10

if (A != 0) AND ((B / A) >= 5) then
  print "B / A " (B / A)
else
  print "(B / A) < 5 oder Division durch Null verhindert"
endif

Die Evaluierung des boolschen Ausdruck wird im Fall A = 0 nach der Auswertung von A != 0 abgebrochen, da das Resultat der AND-Verknüpfung bereits eindeutig unwahr ist.

Siehe auch


Wikimedia Foundation.

Игры ⚽ Нужно сделать НИР?

Schlagen Sie auch in anderen Wörterbüchern nach:

  • Short-circuit evaluation — Evaluation strategies Strict evaluation Applicative order Call by value Call by reference Call by sharing Call by copy restore Non strict evaluation Normal order Call by name Call by need/Lazy evaluation Call by …   Wikipedia

  • Short Circuit Evaluation —   [dt. Kurzschlussauswertung], Kurzschluss …   Universal-Lexikon

  • Short circuit (disambiguation) — *A short circuit is a fault whereby electricity moves through a circuit in an unintended path, potentially causing overheating, fire or explosionShort circuit can also refer to: *Short circuit evaluation, in computer programming, the… …   Wikipedia

  • Evaluation strategy — Evaluation strategies Strict evaluation Applicative order Call by value Call by reference Call by sharing Call by copy restore Non strict evaluation Normal order Call by name Call by need/Lazy evaluation …   Wikipedia

  • Evaluation (disambiguation) — Evaluation is the process of characterizing and appraising something of interest or of determining the value of an expression (mathematics). Computer science * determining the value of an expression (programming) * Eager evaluation or strict… …   Wikipedia

  • RL circuit — A resistor inductor circuit (RL circuit), or RL filter or RL network, is one of the simplest analogue infinite impulse response electronic filters. It consists of a resistor and an inductor, either in series or in parallel, driven by a voltage… …   Wikipedia

  • RC circuit — Linear analog electronic filters Network synthesis filters Butterworth filter Chebyshev filter Elliptic (Cauer) filter Bessel filter Gaussian filter Optimum L (Legendre) filter Linkwitz Riley filter …   Wikipedia

  • Suzuka Circuit — Motorsport venue Name = Suzuka International Racing Course | Location = Suzuka, Mie Prefecture, Japan Time = GMT +9 Events = Formula One Length km = 5.807 Length mi = 3.608 Turns = 17 Record time = 1:29.599 Record driver = flagicon|BRA Felipe… …   Wikipedia

  • C syntax — The syntax of the C programming language is a set of rules that specifies whether the sequence of characters in a file is conforming C source code. The rules specify how the character sequences are to be chunked into tokens (the lexical grammar) …   Wikipedia

  • C++ — The C++ Programming Language, written by its architect, is the seminal book on the language. Paradigm(s) Multi paradigm:[1] procedural …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”