Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2024.1.0 - Русский


mtlb_int16

Matlab int16 emulation function

Description

Matlab and Scilab int16 behave differently :

  • Beyong the main interval bounds, Scilab's int16() wraps, while Matlab's mtlb_int16() saturates.
  • For non integer values, Scilab's int16() truncates the fractional part, while Matlab's mtlb_int16() rounds to the nearest integer.

xint16(x)mtlb_int16(x)
%nan00
-%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.21010
10.51011
10.511011
32767+3276732767
32768-3276832767
32769-3276732767
32770-3276632767
%inf+3276732767

mtlb_int16 has not to be used for hand coded functions.

The function mtlb_int16(A) is used by mfile2sci to replace int16(A) when it is not possible to know what is the input while porting Matlab code to Scilab. This function then determines the correct semantic at run time.

Report an issue
<< mtlb_imp compatibility_functions mtlb_int32 >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Jun 17 17:55:12 CEST 2024