Documentation Center

  • Trial Software
  • Product Updates

fixed.aggregateType

Compute aggregate numerictype

Syntax

aggNT = fixed.aggregateType(A,B)

Description

aggNT = fixed.aggregateType(A,B) computes the smallest binary point scaled numerictype that is able to represent both the full range and precision of inputs A and B.

Input Arguments

A

An integer, binary point scaled fixed-point fi object, or numerictype object.

B

An integer, binary point scaled fixed-point fi object, or numerictype object.

Output Arguments

aggNT

A numerictype object.

Examples

Compute the aggregate numerictype of two numerictype objects.

% can represent range [-4,4) and precision 2^-13
a_nt = numerictype(true,16,13); 
% can represent range [-2,2) and precision 2^-16
b_nt = numerictype(true,18,16); 

% can represent range [-4,4) and precision 2^-16
aggNT = fixed.aggregateType(a_nt,b_nt)
aggNT =
 

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

Compute the aggregate numerictype of two fi objects.

% Unsigned, WordLength: 16, FractionLength: 14
a_fi = ufi(pi,16); 
% Signed, WordLength: 24, FractionLength: 21
b_fi = sfi(-pi,24); 

% Signed, WordLength: 24, FractionLength: 21
aggNT = fixed.aggregateType(a_fi,b_fi)
aggNT =
 

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 24
        FractionLength: 21
 

Compute the aggregate numerictype of a fi object and an integer.

% Unsigned, WordLength: 16, FractionLength: 14
% can represent range [0,3] and precision 2^-14
a_fi = ufi(pi,16);
% Unsigned, WordLength: 8, FractionLength: 0
% can represent range [0,255] and precision 2^0
cInt = uint8(0); 

% Unsigned with WordLength: 14+8, FractionLength: 14
% can represent range [0,255] and precision 2^-14
aggNT = fixed.aggregateType(a_fi,cInt)
aggNT =
 

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 22
        FractionLength: 14

See Also

|

Was this topic helpful?