mtlb_int32
Matlab int32 emulation function
Description
Matlab and Scilab int32
behave differently :
- Beyong the main interval bounds, Scilab's
int32()
wraps, while Matlab'smtlb_int32()
saturates. - For non integer values, Scilab's
int32()
truncates the fractional part, while Matlab'smtlb_int32()
rounds to the nearest integer.
Let imin = -(2^16) = -2147483648
and imax = 2^16 - 1 = 2147483647
.
x | int32(x) | mtlb_int32(x) |
---|---|---|
%nan | 0 | 0 |
-%inf | imin | imin |
imin-2 | imax-1 | imin |
imin-1 | imax | imin |
imin | imin | imin |
imin-1 | imin-1 | imin-1 |
-80.7 | -80 | -81 |
-80.5 | -80 | -81 |
-80.4 | -80 | -80 |
10.2 | 10 | 10 |
10.5 | 10 | 11 |
10.51 | 10 | 11 |
imax | imax | imax |
imax+1 | imin | imax |
imax+2 | imin+1 | imax |
imax+3 | imin+2 | imax |
%inf | imax | imax |
The function |
Report an issue | ||
<< mtlb_int16 | compatibility_functions | mtlb_int64 >> |