Possible Duplicate:
How do I get real integer overflows in MATLAB/Octave?
I'm writing a Matlab routine that would help me simulate something I will eventually code in C++. One problem is that Matlab and C++ ints behave differently when performing arithmetic operations that cause produce results larger than the container can hold.
For example, in Matlab intmax('uint16')
produces 65535
. And intmax('uint16')+1
still produces 65535
. If you want to go higher than 65535, you can't. Matlab simply puts a cap on it.
C++ is different. Writing unsigned short x = 65535; cout << ++x;
produces 0
because it performs the addition fully and simply keeps 16 least significant bits.
Is there a way of making Matlab behave the same way?