RosettaCodeData/Task/Detect-division-by-zero/FreeBASIC/detect-division-by-zero.basic

26 lines
488 B
Plaintext

' FB 1.05.0 Win64
Const divByZeroResult As Integer = -9223372036854775808
Sub CheckForDivByZero(result As Integer)
If result = divByZeroResult Then
Print "Division by Zero"
Else
Print "Division by Non-Zero"
End If
End Sub
Dim As Integer x, y
x = 0 : y = 0
CheckForDivByZero(x/y) ' automatic conversion to type of parameter which is Integer
x = 1
CheckForDivByZero(x/y)
x = -1
CheckForDivByZero(x/y)
y = 1
CheckForDivByZero(x/y)
Print
Print "Press any key to exit"
Sleep