Spot the error
Fun with integers
Issue: 13.5 (September/October 2015)
Author: Markus Winter
Author Bio: Markus is a Molecular Biologist who taught himself REALbasic programming in 2003 to let the computer deal with some exceedingly tedious lab tasks. Some call it lazy, he thinks it smart. He still thinks of himself as an advanced beginner at best.
Article Description: No description available.
Article Length (in bytes): 7,491
Starting Page Number: 13
Article Number: 13503
Related Link(s): None
Excerpt of article text...
I was going over my code, cleaning it up and preparing it for Xojo 64-bit, paying particularly close attention to integers and potential overflow errors. I had thought I was done with overflow errors, but they find new ways to annoy me. Have a look at the following code and guess which ones evaluate to
trueand which ones result in
false(and no peeking at the solution!):
Dim n1 As Integer = 3123456789
MsgBox Str(n1 >= 0)
Dim n2 As UInt32 = 3123456789
MsgBox Str(n2 >= 0)
...End of Excerpt. Please purchase the magazine to read the full article.