How do I get real integer overflows in MATLAB/Octave?
Posted
by marvin2k
on Stack Overflow
See other posts from Stack Overflow
or by marvin2k
Published on 2010-03-11T13:32:06Z
Indexed on
2010/03/12
17:37 UTC
Read the original article
Hit count: 359
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
ans = -2147483648
Later on, it would be helpful if I can define the bit width of a variable, but that is not so important right now.
When I build a C-like example, where a variable gets increased until it's smaller than zero, it spins forever and ever:
test = int32(2^30);
while (test > 0)
test = test + int32(1);
end
Another approach I tried was a custom "overflow"-routine which was called every time after a number is changed. This approach was painfully slow, not practicable and not working in all cases at all. Any suggestions?
© Stack Overflow or respective owner