mtlb_int16
Matlab int16 emulation function
Description
Matlab and Scilab int16 behave differently :
- Beyong the main interval bounds, Scilab's
int16()wraps, while Matlab'smtlb_int16()saturates. - For non integer values, Scilab's
int16()truncates the fractional part, while Matlab'smtlb_int16()rounds to the nearest integer.
| x | int16(x) | mtlb_int16(x) |
|---|---|---|
| %nan | 0 | 0 |
| -%inf | -32768 | -32768 |
| -32770 | +32766 | -32768 |
| -32769 | +32767 | -32768 |
| -32768 | -32768 | -32768 |
| -32767 | -32767 | -32767 |
| -80.7 | -80 | -81 |
| -80.5 | -80 | -81 |
| -80.4 | -80 | -80 |
| 10.2 | 10 | 10 |
| 10.5 | 10 | 11 |
| 10.51 | 10 | 11 |
| 32767 | +32767 | 32767 |
| 32768 | -32768 | 32767 |
| 32769 | -32767 | 32767 |
| 32770 | -32766 | 32767 |
| %inf | +32767 | 32767 |
![]() |
The function |
| Report an issue | ||
| << mtlb_imp | compatibility_functions | mtlb_int32 >> |
