06-03-2023, 03:26 PM
That reminds me of an error that apparently occurred quite often in the days of 8 and 16 bit computers (from Code Complete First Edition): The programmer didn't take into account that the result of a calculation no longer fits into the relevant variable.
The program works correctly as long as the sum stays within the bounds of an integer. A nice logical mistake!
Code Complete 2 (Github)
Code Complete 2
And the First Edition (Book), in English:
Code Complete First Edition
The program works correctly as long as the sum stays within the bounds of an integer. A nice logical mistake!
Code: (Select All)
'Beispiel fuer Ueberlauf - 3. Juni 2023
Option _Explicit
Dim As Integer wert1, wert2, ergebnis
Locate 2, 2
Print "Example for an overflow"
Locate 4, 2
Input "Number between 1 to 32768: ", wert1
Locate 5, 2
Input "Number between 1 to 32768: ", wert2
ergebnis = wert1 + wert2
Locate CsrLin + 2, 2
Print Using "Das Ergebnis = ###,###"; ergebnis
End
Code Complete 2 (Github)
Code Complete 2
And the First Edition (Book), in English:
Code Complete First Edition