Overflow without error?

  • Thread starter Thread starter jamie
  • Start date Start date
J

jamie

Is there a way to prevent an overflow of a variable?
Or is the only(/best) way is to do a try-catch statement?

The idea is that i can have an integer (signed or unsigned)
that just keeps rolling over. 0000 to FFFF and back to
0000.

Thanks for all help.
 
Hi,

Disable overflow checking option: Go to project properties dialog -
Configuration Properties/Optimizations. Check Remove integer overflow
checkes.

If you are using command line compiler, use /removeintchecks+ option.


Is there a way to prevent an overflow of a variable?
Or is the only(/best) way is to do a try-catch statement?

The idea is that i can have an integer (signed or unsigned)
that just keeps rolling over. 0000 to FFFF and back to
0000.

Thanks for all help.
 
No, but there is a uint16.
Okay so maybe it is a structure and doing math on it is a
little harder.... Details.. details..*sigh* :p
 
* "jamie said:
No, but there is a uint16.
Okay so maybe it is a structure and doing math on it is a
little harder.... Details.. details..*sigh* :p

Unsigned integer datatypes are not CLS compliant, so you should avoid to
use them. In VB 2005, full support for unsigned data types will be
available.
 
Jamie,
Just be warned that option effects your entire project. Which is all
classes, forms, controls in your project.

Which may be much more then you need.

If I used the option, I would put a comment at the top of the respective
file, so as your successors know why you need the option set, and consider
isolating the respective file to the smallest assembly (class library)
possible.

Hope this helps
Jay
 
Back
Top