Matlab uint8 emulation function
Matlab and Scilab uint8
behave differently :
uint8()
wraps,
while Matlab's mtlb_uint8()
saturates.uint8()
truncates the
fractional part, while Matlab's mtlb_uint8()
rounds to the
nearest integer.x | uint8(x) | mtlb_uint8(x) |
---|---|---|
%nan | 0 | 0 |
-%inf | 0 | 0 |
-2 | 254 | 0 |
-1 | 255 | 0 |
0 | 0 | 0 |
2 | 2 | 2 |
10.2 | 10 | 10 |
10.5 | 10 | 11 |
10.51 | 10 | 11 |
... | ... | ... |
255 | 255 | 255 |
256 | 0 | 255 |
257 | 1 | 255 |
%inf | 255 | 255 |
![]() |
The function |