You can use a `numerictype`

object to define
common data type and scaling rules that you would like to use for
many `fi`

objects. You can then create multiple `fi`

objects,
using the same `numerictype`

object for each.

In the following example, you create a `numerictype`

object `T`

with
word length `32`

and fraction length `28`

.
Next, to ensure that your `fi`

objects have the same `numerictype`

attributes,
create `fi`

objects `a`

and `b`

using
your `numerictype`

object `T`

.

format long g T = numerictype('WordLength',32,'FractionLength',28)

T = DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 32 FractionLength: 28

a = fi(pi,T)

a = 3.1415926553309 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 32 FractionLength: 28

b = fi(pi/2, T)

b = 1.5707963258028 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 32 FractionLength: 28

In this example, start by creating a `numerictype`

object `T`

with
[Slope Bias] scaling. Next, use that object to create two `fi`

objects, `c`

and `d`

with
the same `numerictype`

attributes:

T = numerictype('Scaling','slopebias','Slope', 2^2, 'Bias', 0)

T = DataTypeMode: Fixed-point: slope and bias scaling Signedness: Signed WordLength: 16 Slope: 2^2 Bias: 0

c = fi(pi, T)

c = 4 DataTypeMode: Fixed-point: slope and bias scaling Signedness: Signed WordLength: 16 Slope: 2^2 Bias: 0

d = fi(pi/2, T)

d = 0 DataTypeMode: Fixed-point: slope and bias scaling Signedness: Signed WordLength: 16 Slope: 2^2 Bias: 0

For more detail on the properties of `numerictype`

objects
see numerictype Object Properties.

Was this topic helpful?