accumpos

Add two fi objects or values

Syntax

c = accumpos(a,b)
c = accumpos(a,b,RoundingMethod)
c = accumpos(a,b,RoundingMethod,OverflowAction)

Description

c = accumpos(a,b) adds a and b using the a's data type. b is cast into a's data type. If a is a fi object, the default 'Floor' rounding method and default 'Wrap' overflow action are used. The fimath properties of a and b are ignored.

c = accumpos(a,b,RoundingMethod) uses the rounding method specified in RoundingMethod.

c = accumpos(a,b,RoundingMethod,OverflowAction) uses the overflow action specified in OverflowAction.

Input Arguments

a

Number to add. a can be fi object or double, single, logical, or integer value. The data type of a is used to compute the output data type.

b

Number to add. b can be fi object or double, single, logical, or integer value.

RoundingMethod

Rounding method to use if a is a fi object. Valid values are 'Ceiling', 'Convergent', 'Floor', 'Nearest', 'Round', and 'Zero'.

Default: Floor

OverflowAction

Overflow action to take if a is a fi object. Valid values are 'Saturate' and 'Wrap'.

Default: Wrap

Output Arguments

c

Result of adding the a and b inputs.

Examples

Add two fi numbers using default accumpos settings and then, using nondefault rounding method and overflow action.

a = fi(pi,1,16,13);
b = fi(1.5,1,16,14);
add_default  = accumpos(a,b);
add_custom = accumpos(a,b,'Nearest','Saturate');

See Also

Was this topic helpful?