storedInteger - Get stored integer value of fi object - MATLAB (original) (raw)

Main Content

Get stored integer value of fi object

Syntax

Description

[y](#mw%5Fde6a47fb-916c-4f2c-bf6e-cb71ce26f113) = storedInteger([a](#mw%5F3e0d4cd1-cebb-4408-b271-df13af902152)) returns the stored integer value of fi object a. The stored integer y is returned as one of the built-in integer data types.

The real-world value of a fi object can be represented as

When the bias is zero and the slope is a power of two, commonly called binary-point scaling, this is often represented as

example

Examples

collapse all

This example shows how to use the storedInteger function to determine the stored integer values of two fi objects.

Define the fi object a using the default fixed-point data type.

a = fi([0.2 0.3 0.4 0.5]); in_a = storedInteger(a)

in_a = 1×4 int16 row vector

6554    9830   13107   16384

The stored integer values for fi object a are returned in the int16 data type because the fi constructor creates a fi object with a signed 16-bit data type by default.

Define the fi object a_nt using the fixed-point data type specified by the numerictype object nt.

nt = numerictype('WordLength',17); a_nt = fi([0.2 0.3 0.4 0.5; 0.2 0.3 0.4 0.5],'numerictype',nt); in_a_nt = storedInteger(a_nt)

in_a_nt = 2×4 int32 matrix

6554    9830   13107   16384
6554    9830   13107   16384

The stored integer values for fi object a_nt are returned in the int32 data type because this is the smallest built-in integer data type with at least 17 bits.

Input Arguments

collapse all

Fixed-point numeric object from which to get the stored integer value, specified as a scalar, vector, matrix, or multidimensional array fi object.

Data Types: fi
Complex Number Support: Yes

Output Arguments

collapse all

Stored integer value of input fi object a, returned as one of the built-in integer data types. The output has the same dimensions as the input. The data type of the output determined based on the signedness and word length (WL) of the stored integer:

Word Length of Input Data Type of Output
WL ≤ 8 bits int8 or uint8
8 bits < WL ≤ 16 bits int16 or uint16
16 bits < WL ≤ 32 bits int32 or uint32
32 bits < WL ≤ 64 bits int64 or uint64

Data Types: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Limitations

Tips

Alternative Functionality

Function

The int andstoredInteger functions both return the stored integer value of afi object. You can use the int function to both get and set the stored integer of a fi object:

a = fi(pi); y = int(a) %get

a = fi(pi); a.int = 3; %set y = a.int %get

You can use the storedInteger function only to get the stored integer value of a fi object.

a = fi(pi); y = storedInteger(a)

The storedInteger function cannot be used to set the stored integer value of a fi object.

Extended Capabilities

Version History

Introduced in R2012a