fxpmath
fxpmath copied to clipboard
Possible bug: flags not propagated
Consider this code snippet:
a = Fxp(-2., dtype="fxp-s24/8")
b = Fxp(2.15, dtype="fxp-s24/8")
assert b.status['inaccuracy']
c = a+b
# This fails:
assert c.status['inaccuracy']
It might make sense for the inaccuracy and other flags to be propagated through operations.
What do you think?
hello @edschofield,
You're right, inaccuracy
flag should be propagated in these cases. This must be added to next patch!
Now, c
only raises inaccuracy
flag according the result of a_ + b
, where a_
has a new (inaccurate) value. In other words, c
could be inaccurate despite a
or b
value are accurate. In the case of flag propagation you'd have to inspect if the inaccuracy
of c
is because one of the operands or not, but I think it's fair enough. It's more valuable for the user to know if c
is inaccurate despite of the reasons.
About the overflow
, underflow
flags, maybe it would be right to propagate to inaccuracy
also if it's used as operand. Does it sound correct for you? I'm not sure because it won't be an inaccurate value but an wrong value!