| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Fixed-Point Toolbox |
| Contents | Index |
| Learn more about Fixed-Point Toolbox |
c = F.add(a,b)
c = F.add(a,b) adds objects a and b using fimath object F. This is helpful in cases when you want to override the fimath objects of a and b, or if the fimath properties associated with a and b are different. The output fi object c is always associated with the global fimath.
a and b must have the same dimensions unless one is a scalar. If either a or b is scalar, then c has the dimensions of the nonscalar object.
If either a or b is a fi object, and the other is a MATLAB built-in numeric type, then the built-in object is cast to the word length of the fi object, preserving best-precision fraction length.
In this example, c is the 32-bit sum of a and b with fraction length 16:
a = fi(pi);
b = fi(exp(1));
F = fimath('SumMode','SpecifyPrecision','SumWordLength',32,...
'SumFractionLength',16);
c = F.add(a,b)
c =
5.8599
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 16
c = F.add(a,b) is similar to
a.fimath = F;
b.fimath = F;
c = a + b
c =
5.8599
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 16
RoundMode: nearest
OverflowMode: saturate
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: SpecifyPrecision
SumWordLength: 32
SumFractionLength: 16
CastBeforeSum: truebut not identical. When you use add, the fimath properties of a and b are not modified, and the output fi object c is associated with the global fimath. When you use the syntax c = a + b, where a and b have their own fimath objects, the output fi object c gets assigned the same fimath object as inputs a and b. See fimath Rules for Fixed-Point Arithmetic in the Fixed-Point Toolbox User's Guide for more information.
divide, fi, fimath, mpy, mrdivide, numerictype, rdivide, sub, sum
![]() | abs | all | ![]() |

Learn how to apply early verification to your development process through these technical resources.
How much time do you spend on testing to ensure implementation meets system-level requirements?
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |