# sfi

Construct signed fixed-point numeric object

## Description

example

a = sfi is the default constructor and returns a signed fi object with no value, 16-bit word length, and 15-bit fraction length.

The fi object created by the sfi constructor function has data properties, fimath properties, and numerictype properties. These properties are described in detail in fi Object Properties, fimath Object Properties and numerictype Object Properties.

The fi object created by the sfi constructor function has no local fimath object. You can attach a fimath object to that fi object if you do not want to use the default fimath settings. For more information, see fimath Object Construction.

example

a = sfi(v) returns a signed fixed-point object with value v, 16-bit word length, and best-precision fraction length. Best-precision is when the fraction length is set automatically to accommodate the value v for the given word length.

example

a = sfi(v,w) returns a signed fixed-point object with value v, word length w, and best-precision fraction length.

example

a = sfi(v,w,f) returns a signed fixed-point object with value v, word length w, and fraction length f.

a = sfi(v,w,slope,bias) returns a signed fixed-point object with value v, word length w, slope, and bias.

a = sfi(v,w,slopeadjustmentfactor,fixedexponent,bias) returns a signed fixed-point object with value v, word length w, slopeadjustmentfactor, fixedexponent, and bias.

## Examples

collapse all

The default constructor returns a signed fi object with no value, 16-bit word length, and 15-bit fraction length.

a = sfi
a =

[]

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

Create a signed fi object with the default word length of 16 bits and best-precision fraction length.

a = sfi(pi)
a =

3.1416

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

If you omit the argument f, the fraction length is set automatically to the best precision possible.

a = sfi(pi,8)
a =

3.1563

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 8
FractionLength: 5

Create a signed fi object with a value of pi, a word length of 8 bits, and a fraction length of 3 bits.

a = sfi(pi,8,3)
a =

3.1250

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 8
FractionLength: 3

Default fimath properties are associated with a. When a fi object does not have a local fimath object, no fimath object properties are displayed in its output. To determine whether a fi object has a local fimath object, use the isfimathlocal function.

isfimathlocal(a)
ans =
0

A returned value of 0 means the fi object does not have a local fimath object. When the isfimathlocal function returns a 1, the fi object has a local fimath object.

The value v can also be an array.

a = sfi((magic(3)/10),16,12)
a =

0.8000    0.1001    0.6001
0.3000    0.5000    0.7000
0.3999    0.8999    0.2000

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

## Input Arguments

collapse all

Value of the signed fi object, specified as a scalar, vector, matrix, or multidimensional array.

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

Word length, in bits, of the signed fi object, specified as a scalar integer.

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

Fraction length, in bits, of the signed fi object, specified as a scalar integer. If you do not specify a fraction length, the signed fi object automatically uses the fraction length that gives the best precision while avoiding overflow for the specified value and word length.

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

Slope of the scaling, specified as a scalar integer. The following equation represents the real-world value of a slope bias scaled number.

$real-worldvalue=\left(slope×integer\right)+bias$

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

Bias of the scaling, specified as a scalar. The following equation represents the real-world value of a slope bias scaled number.

$real-worldvalue=\left(slope×integer\right)+bias$

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

The slope adjustment factor of a slope bias scaled number. The following equation demonstrates the relationship between the slope, fixed exponent, and slope adjustment factor.

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

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

The fixed exponent of a slope bias scaled number. The following equation demonstrates the relationship between the slope, fixed exponent, and slope adjustment factor.

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

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

## Version History

Introduced in R2009b