> What happens when PBP divides a number by 0?
That depends on how you are using them.
If you have BYTE sized variables, and are returning the result to a byte sized variable, the result is 255.
Code:
A VAR BYTE
B VAR BYTE
C VAR BYTE
A = 100
B = 0
C = A / B
LCDOUT dec C
; Displays 255
If the result is being returned to a Word variable, the result will be 65535.
Code:
A VAR BYTE
B VAR BYTE
C VAR WORD
A = 100
B = 0
C = A / B
LCDOUT dec C
; Displays 65535
And if the division is done inside another formula or Statement like LCDOUT, the result is assumed to be word sized, and the result will be 65535 ...
Code:
A VAR BYTE
B VAR BYTE
A = 100
B = 0
LCDOUT dec (A / B)
; displays 65535, even though the variables are Byte sized.
For word variables, the result will always be 65535
And finally, if the zero is in a constant expression, the compiler will flag an error
Code:
LCDOUT $FE,$C0, dec 100/0
; Compiler error: Divide by zero while constant folding.
HTH,
Bookmarks