Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.1.0 - 日本語


mtlb_int32

Matlab int32 emulation function

Description

Matlab and Scilab int32 behave differently :

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

Let imin = -(2^16) = -2147483648 and imax = 2^16 - 1 = 2147483647.

xint32(x)mtlb_int32(x)
%nan00
-%infiminimin
imin-2imax-1imin
imin-1imaximin
iminiminimin
imin-1imin-1imin-1
-80.7-80-81
-80.5-80-81
-80.4-80-80
10.21010
10.51011
10.511011
imaximaximax
imax+1iminimax
imax+2imin+1imax
imax+3imin+2imax
%infimaximax

mtlb_int32 has not to be used for hand coded functions.

The function mtlb_int32(A) is used by mfile2sci to replace int32(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_int16 compatibility_functions mtlb_int64 >>

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 May 22 12:43:16 CEST 2023