1-bit Matlab fixed-point behavior

I noticed a funny behavior with Matlab-FI numbers. This only happens with a 1-bit signed number (a data type that in practice does not make much sense). I know that multiplying the double with fi is not good practice, and the behavior may even depend on the version of Matlab, but I would expect the behavior to be the same regardless of the number of bits. This seems to be consistent with versions 2011b, 2013a and 2013b, and I would like to understand why this happens.

Example 1: -1 can be represented as 1-bit, signed. However, the result has a fractional part of -2, which allows only numbers [-8, -4, 0, 4]

>> a = fi(-1,1,1,0)
a = -1
      s1,0

>> 1*a
ans = 0
      s2,-2

Example 2: 1-bit, unsigned behaves as expected, part of the fraction does not change

>> b = fi(1,0,1,0)
b = 1
      u1,0

>> 1*b
ans = 1
      u2,0

3: 2-, , ,

>> c = fi(-2,1,2,0)
c = -2
      s2,0

>> 1*c
ans = -2
      s4,0

4: 1-, , , 1.

>> d = fi(-0.5,1,1,1)
d = -0.5000
      s1,1

>> 1*d
ans = 0
      s2,-1
+4
2

Matlab , , , . 1 , , 0, , , .

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

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

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

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
+3

: ( ) MathWorks, . , 1- , ( sebas), , , .


, (, 1) FI (, *), . FI " ", .

MATLAB fi(), :

1.

>> a = fi(-1,1,1,0)
a =
    -1
    s1,0

>> fi(1,a.SignednessBool,a.WordLength) * a
ans =
    0
    s2,-2

>> 1*a
ans =
    0
    s2,-2

2.

>> b = fi(1,0,1,0)
b =
    1
    u1,0

>> fi(1,b.SignednessBool,b.WordLength) * b
ans =
    1
    u2,0

>> 1 * b
ans =
    1
    u2,0

3.

>> c = fi(-2,1,2,0)
c =
    -2
    s2,0

>> fi(1,c.SignednessBool,c.WordLength) * c
ans =
    -2
    s4,0

>> 1 * c
ans =
    -2
    s4,0

4.

>> d = fi(-0.5,1,1,1)
d =
    -0.5000
    s1,1

>> fi(1,d.SignednessBool,d.WordLength) * d
ans =
    0
    s2,-1

>> 1*d
ans =
    0
    s2,-1

, (, 1).

+1

All Articles