2

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?

Community
  • 1
  • 1
Phonon
  • 12,549
  • 13
  • 64
  • 114
  • Take a look over to : http://stackoverflow.com/questions/2425251/how-do-i-get-real-integer-overflows-in-matlab-octave . I like the overload function method. – Eugene K Jun 10 '11 at 16:57

0 Answers0