Matlab int8 emulation function
Matlab and Scilab int8 behave differently :
int8() wraps,
while Matlab's mtlb_int8() saturates.int8() truncates the
fractional part, while Matlab's mtlb_int8() rounds to the
nearest integer.| x | int8(x) | mtlb_int8(x) |
|---|---|---|
| %nan | 0 | 0 |
| -%inf | -128 | -128 |
| -130 | 126 | -128 |
| -129 | 127 | -128 |
| -128 | -128 | -128 |
| -127 | -127 | -127 |
| -80.7 | -80 | -81 |
| -80.5 | -80 | -81 |
| -80.4 | -80 | -80 |
| 10.2 | 10 | 10 |
| 10.5 | 10 | 11 |
| 10.51 | 10 | 11 |
| 127 | 127 | 127 |
| 128 | -128 | 127 |
| 129 | -127 | 127 |
| %inf | 127 | 127 |
![]() |
The function |