Behaviour of Matlab fixed-point numbers with 1-bit

1 view (last 30 days)
I noticed a funny behaviour with Matlab-FI numbers. It occurs only with 1-bit, signed numbers (a datatype that does not make a lot of sense in practice). I'm aware that multiplying a double with a fi is not a good practice and the behaviour may even depend on the Matlab version, but I would expect the behaviour to be same independent on the number of bits. This seems to be consistent in versions 2011b, 2013a and 2013b and I would like to understand why it happens that way.
*Example 1:* -1 can be representet as 1-bit, signed. However the result has a fraction-part of -2 which would allow only numbers [-8, -4, 0, 4]
>> a = fi(-1,1,1,0)
a = -1
s1,0
>> 1*a
ans = 0
s2,-2
*Example 2:* A 1-bit, unsigned behaves as expected, the fraction-part is unchanged
>> b = fi(1,0,1,0)
b = 1
u1,0
>> 1*b
ans = 1
u2,0
*Example 3:* A 2-bit, signed behaves as expected, the fraction-part is unchanged, the integer-part is extended
>> c = fi(-2,1,2,0)
c = -2
s2,0
>> 1*c
ans = -2
s4,0
*Example 4:* Another 1-bit, signed showing a similar behaviour as in example 1.
>> d = fi(-0.5,1,1,1)
d = -0.5000
s1,1
>> 1*d
ans = 0
s2,-1

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!