Learn something new every day
More Info... by email
A logic error is a problem with a computer's programming code that is not readily identified when the code is written or compiled. Sometimes called a semantic error, a logic error generally is the programmer's fault; even if the coding is correct, the resulting answer might yet be incorrect. If the programming language compiler is supplied with a logic error, it will successfully interpret the supplied code, resulting in a working program that might return faulty data.
Logic errors are difficult to catch by the programmer because the programming language interpreter does not identify this error as a problem. After the code is successfully executed, the results, without deliberate examination, might initially appear to be correct. To identify these types of errors, a person who is knowledgeable about the expected results and the program's function should review the output and operation of that program.
To find a logic error in code, one must be able to methodically track the source of the error. The error might be the result of an incorrectly coded syntax. The syntax of code might appear to be correct but might result in a logical error. These types of errors might end up being very costly problems if they are not corrected in a timely manner.
Logical errors also can result from faulty data that was used by a correctly written program without any internal logic errors of its own. This is equivalent to the common expression "garbage in, garbage out." If data is incorrectly entered into the program, even if the program is executed correctly, the result is an error compared with what was expected.
As an example of another type of logic error, while at a stop sign, a driver might choose to turn right or turn left. If the driver turns to the right when the intended destination was to the left, this would be considered a logical error. Technically, the driver operated the vehicle correctly, but the ending result was not as anticipated. As illustrated in this example, errors in logic are not limited to the realm of computer programming. A logic error also might be categorized as a fallacy with regard to communications.
In another example in which logic errors exist, word processors might sometimes use an automated spell checker; these spell checkers are notorious for missing logic errors. For instance, the noun “sale” might be misrepresented by the noun “sail” in a sentence. Each word is spelled correctly, sounds correct and might be grammatically correct within the sentence, but the definition for one word might not fit the context of the particular sentence.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!