Documentation

accumpos

Add twofiobjects or values

Syntax

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

Description

c= accumpos(a,b)addsaandbusing thea’s data type.bis cast intoa’s data type. Ifais afiobject, the default'Floor'rounding method and default'Wrap'overflow action are used. The fimath properties ofaandbare ignored.

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

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

Input Arguments

a

Number to add.acan befiobject or double, single, logical, or integer value. The data type ofais used to compute the output data type.

b

Number to add.bcan befiobject or double, single, logical, or integer value.

RoundingMethod

Rounding method to use ifais afiobject. Valid values are'Ceiling','Convergent','Floor','Nearest','Round', and'Zero'.

Default:Floor

OverflowAction

如果溢出行动ais afiobject. Valid values are'Saturate'and'Wrap'.

Default:Wrap

Output Arguments

c

Result of adding theaandbinputs.

Examples

Add twofinumbers using defaultaccumpossettings 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');

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2012a

Was this topic helpful?