francof2a / fxpmath

A python library for fractional fixed-point (base 2) arithmetic and binary manipulation with Numpy compatibility.
MIT License
183 stars 21 forks source link

Invalid DTypes Allowed #95

Open OliverKillane opened 7 months ago

OliverKillane commented 7 months ago

Given the description for fxp types from the quickstart docs The below patterns should not be possible.

Fxp(a, True, x, f>=x)
Fxp(a, False, x, f>x)

For example

from fxpmath import Fxp

num = Fxp(-3, True, 1, 10)

print(num.dtype) # 'fxp-s1/10'
print(num())     # -0.0009765625
print(num.val)   # -1

There is no failure on construction, and the behaviour in this case is not documented. I am unsure if this is a bug, or a conscious design choice. Please close this if it is the latter.