Matlab uint32 emulation function
Matlab and Scilab uint32 behave differently :
uint32() wraps,
while Matlab's mtlb_uint32() saturates.uint32() truncates the
fractional part, while Matlab's mtlb_uint32() rounds to the
nearest integer.Let imax = 2^32 - 1 = 4294967295.
| x | uint32(x) | mtlb_uint32(x) |
|---|---|---|
| %nan | 0 | 0 |
| -%inf | 0 | 0 |
| -2 | imax-1 | 0 |
| -1 | imax | 0 |
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 10.2 | 10 | 10 |
| 10.5 | 10 | 11 |
| 10.51 | 10 | 11 |
| ... | ... | ... |
| imax | imax | imax |
| imax+1 | 0 | imax |
| imax+1 | 1 | imax |
| %inf | imax | imax |
![]() |
The function |