I\'m working on a verification-tool for some VHDL-Code in MATLAB/Octave. Therefore I need data types which generate \"real\" overflows:
intmax(\'int32\') + 1
I'm not a Java expert, but underlying Java classes available in Matlab should allow handling of overflows like C would. One solution I found, works only for single value, but it converts a number to the int16 (Short) or int32 (Integer) representation. You must do your math using Matlab double, then convert to Java int16 or int32, then convert back to Matlab double. Unfortunately Java doesn't appear to support unsigned types in this way, only signed.
double(java.lang.Short(hex2dec('7FFF')))
ans = 32767
double(java.lang.Short(hex2dec('7FFF')+1))
ans = -32768
double(java.lang.Short(double(intmax('int16'))+1))
ans = -32768
double(java.lang.Integer(hex2dec('7FFF')+1))
ans = 32768
https://www.tutorialspoint.com/java/lang/java_lang_integer.htm