## numerictype Object Properties

### Data Type and Scaling Properties

All properties of a `numerictype` object are writable. However, the `numerictype` properties of a `fi` object become read only after the `fi` object has been created. Any `numerictype` properties of a `fi` object that are unspecified at the time of `fi` object creation are automatically set to their default values. The properties of a `numerictype` object are:

PropertyDescriptionValid Values
`Bias`

Bias associated with the object.

Along with the slope, the bias forms the scaling of a fixed-point number.

• Any floating-point number

`DataType`

Data type category

• `Fixed` (default) — Fixed-point or integer data type

• `boolean` — Built-in MATLAB® `boolean` data type

• `double` — Built-in MATLAB `double` data type

• `ScaledDouble` — Scaled double data type

• `single` — Built-in MATLAB `single` data type

`DataTypeMode`

Data type and scaling associated with the object

• `Fixed-point: binary point scaling` (default) — Fixed-point data type and scaling defined by the word length and fraction length

• `Boolean` — Built-in `boolean`

• `Double` — Built-in `double`

• `Fixed-point: slope and bias scaling` — Fixed-point data type and scaling defined by the slope and bias

• `Fixed-point: unspecified scaling` — Fixed-point data type with unspecified scaling

• `Scaled double: binary point scaling` — Double data type with fixed-point word length and fraction length information retained

• `Scaled double: slope and bias scaling` — Double data type with fixed-point slope and bias information retained

• `Scaled double: unspecified scaling` — Double data type with unspecified fixed-point scaling

• `Single` — Built-in `single`

`FixedExponent`

Fixed-point exponent associated with the object

• Any integer

Note

The `FixedExponent` property is the negative of the `FractionLength`. Changing one property changes the other.

`FractionLength`

Fraction length of the stored integer value, in bits

• Best precision fraction length based on value of the object and the word length (default)

• Any integer

Note

The `FractionLength` property is the negative of the `FixedExponent`. Changing one property changes the other.

`Scaling`

Scaling mode of the object

• `BinaryPoint` (default) — Scaling for the `fi` object is defined by the fraction length.

• `SlopeBias` — Scaling for the `fi` object is defined by the slope and bias.

• `Unspecified` — A temporary setting that is only allowed at `fi` object creation, to allow for the automatic assignment of a binary point best-precision scaling.

`Signed`

Whether the object is signed

Note

Although the `Signed` property is still supported, the `Signedness` property always appears in the `numerictype` object display. If you choose to change or set the signedness of your `numerictype` objects using the `Signed` property, MATLAB updates the corresponding value of the `Signedness` property.

• `true` (default) — signed

• `false` — unsigned

• `1` — signed

• `0` — unsigned

• `[]` — auto

`Signedness`

Whether the object is signed, unsigned, or has an unspecified sign

• `Signed` (default)

• `Unsigned`

• `Auto` — unspecified sign

`Slope`

Slope associated with the object

Along with the bias, the slope forms the scaling of a fixed-point number.

• Any finite floating-point number greater than zero

Note

`$slope=slopeadjustmentfactor×{2}^{fixedexponent}$`

Changing one of these properties changes the other.

`SlopeAdjustmentFactor`

Slope adjustment associated with the object

The slope adjustment is equivalent to the fractional slope of a fixed-point number.

• Any number greater than or equal to 1 and less than 2

Note

`$slope=slopeadjustmentfactor×{2}^{fixedexponent}$`

Changing one of these properties changes the other.

`WordLength`

Word length of the stored integer value, in bits

• `16` (default)

• Any positive integer if `Signedness` is `Unsigned` or unspecified

• Any integer greater than one if `Signedness` is set to `Signed`

These properties are described in detail in the fi Object Properties. To learn how to specify properties for `numerictype` objects in Fixed-Point Designer™ software, refer to Set numerictype Object Properties.

### How Properties are Related

#### Properties that affect the slope

The Slope field of the `numerictype` object is related to the `SlopeAdjustmentFactor` and `FixedExponent` properties by

`$slope=slopeadjustmentfactor×{2}^{fixedexponent}$`

The `FixedExponent` and `FractionLength` properties are related by

`$fixedexponent=-fractionlength$`

If you set the `SlopeAdjustmentFactor`, `FixedExponent`, or `FractionLength` property, the Slope field is modified.

#### Stored integer value and real world value

In binary point scaling the `numerictype` `StoredIntegerValue` and `RealWorldValue` properties are related according to

`$real\text{-}worldvalue=storedintegervalue×{2}^{-fractionlength}$`

In [Slope Bias] scaling the `RealWorldValue` can be represented by

which is equivalent to

`$real\text{-}worldvalue=\left(slope×storedinteger\right)+bias$`

If any of these properties are updated, the others are modified accordingly.

### Set `numerictype` Object Properties

#### Setting `numerictype` Properties at Object Creation

You can set properties of `numerictype` objects at the time of object creation by including properties after the arguments of the `numerictype` constructor function.

For example, to set the word length to 32 bits and the fraction length to 30 bits,

`T = numerictype('WordLength',32,'FractionLength',30)`
```T = DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 32 FractionLength: 30 ```

In addition to creating a `numerictype` object at the command line, you can also set `numerictype` properties using the Insert numerictype Constructor dialog box. For an example of this approach, see Example: Build numerictype Object Constructors in a GUI.

#### Use Direct Property Referencing with numerictype Objects

You can reference directly into a property for setting or retrieving `numerictype` object property values using MATLAB structure-like referencing. You do this by using a period to index into a property by name.

For example, to get the word length of `T`,

`T.WordLength`
```ans = 32 ```

To set the fraction length of `T`,

`T.FractionLength = 31`
```T = DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 32 FractionLength: 31 ```

Get trial now