When matlab is multiplying numbers with different format, it is changing the first of all modifying the formats. If you convert the 1
to the same format as your value, sometimes the number one in this format is 0
, so it makes sense that the product is zero, and everything is as expected.
Example 1
a = fi(-1,1,1,0); a_one = fi(1,1,1,0); disp([a, a_one, a*a_one])
-1 0 0
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 1
FractionLength: 0
Example 2
b = fi(1,0,1,0); b_one = fi(1,0,1,0); disp([b, b_one, b*b_one])
1 1 1
DataTypeMode: Fixed-point: binary point scaling
Signedness: Unsigned
WordLength: 1
FractionLength: 0
Example 3
c = fi(-2,1,2,0); c_one = fi(1,1,2,0); disp([c, c_one, c*c_one])
-2 1 -2
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 2
FractionLength: 0
Example 4
d = fi(-0.5,1,1,1); d_one = fi(1,1,1,1); disp([d, d_one, d*d_one])
-0.500000000000000 0 0
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 1
FractionLength: 1