Cast an integer data type to equivalent
Cast an Integer to a
cast64BitIntToFi functions to cast integer data types in your code
Create a variable with a signed 16-bit integer data type. Cast the variable to an
fi object using the
u = int16(25); y1 = castIntToFi(u)
y1 = 25 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 0
fi object has the same word length and signedness as
the input, and zero fraction length.
cast64BitIntToFi function casts only 64-bit integer data
types to an equivalent
fi object. All other input data types retain
their data type.
In this example, because the input is not an
uint64 data type, the output remains an
y2 = cast64BitIntToFi(u)
y2 = int16 25
When you pass an
int64 into the
cast64BitIntToFi function, the output is a
object with a 64-bit word length and zero fraction length.
u = int64(25); y3 = castIntToFi(u)
y3 = 25 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 64 FractionLength: 0
u — Numeric input
scalar | vector | matrix | multidimensional array
Numeric input array, specified as a scalar, vector, matrix, or multidimensional array.
Complex Number Support: Yes
y — Fixed-point output
fi object | scalar | vector | matrix | multidimensional array
Numeric output, returned as a scalar, vector, matrix, or multidimensional array with the same value and dimensions as the input.
When the data type of
u is an integer type, the output is a
fi object with the same word length and signedness as the input, and
a fraction length of zero. Otherwise, the output has the same data type as the