cast64BitFiToInt

Cast fi object types that can be exactly represented to a 64-bit integer data type

Description

example

y = cast64BitFiToInt(u) casts the input u to an equivalent 64-bit integer data type when possible.

If the input u is a fi object that can be represented exactly by an int64 or uint64 data type, then the output is this built-in data type. If u is a fi object that cannot be exactly represented by a built-in data type, or if it is already a built-in data type, then the output is the same as the input.

Examples

collapse all

Use the castFiToInt and cast64BitFiToInt functions to cast fi objects to equivalent integer data types.

Create a signed fi variable with a 16-bit word length and zero fraction length. This is equivalent to an int16 data type. Cast the variable to the equivalent integer data type using the castFiToInt function.

u = fi(25,1,16,0);
y1 = castFiToInt(u)
y1 =

int16

25

The cast64BitFiToInt function casts only 64-bit word length fi objects with zero fraction length to an equivalent integer data type. All other input data types retain their original data type.

In this example, because the input is not a 64-bit word length fi, the output is the same as the input.

y2 = cast64BitFiToInt(u)
y2 =

25

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 0

When you pass a fi object with a 64-bit word length and zero fraction length into the cast64BitFiToInt function, the output is an int64.

u = fi(25,1,64,0)
y3 = cast64BitFiToInt(u)
y3 =

int64

25

When the input is a fi object with a non-zero fraction length, both functions return the original fi object because the input cannot be represented by an integer data type.

u = fi(pi,1,64,32);
y4 = cast64BitFiToInt(u)
y4 =

3.1416

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 64
FractionLength: 32
y5 = castFiToInt(u)
y5 =

3.1416

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 64
FractionLength: 32

Input Arguments

collapse all

Numeric input array, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: double | single | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
Complex Number Support: Yes

Output Arguments

collapse all

Numeric output, returned as a scalar, vector, matrix, or multidimensional array with the same value and dimensions as the input.

If the input u is a fi object that can be represented exactly by an int64 or uint64 data type, then the output is this built-in data type. If u is a fi object that cannot be exactly represented by a built-in data type, or if it is already a built-in data type, then the output is the same as the input. 