Schweitzer-Engineering-Laboratories / fixedpoint

Fixed point arithmetic python package
BSD 3-Clause "New" or "Revised" License
35 stars 7 forks source link

Add division capability. #2

Open ZackSheffieldSEL opened 4 years ago

ZackSheffieldSEL commented 4 years ago

As of 1.0.0, the __truediv__ and __floordiv__ operators return NotImplemented.

Here are some resources for implemented fixed point division:

heteloo commented 2 years ago

You can use the division algorithm simply by making it a function. (I'm a beginner, so I don't know if this is a good way.)

zks0002 commented 2 years ago

@heteloo, you are correct, but the idea of division for fixed point arithmetic is somewhat ambiguous. The 2 links in my first comment address ways to implement division, but given that fixed-point division is a somewhat niche and specialized operation I think it probably makes sense to leave the division operation undefined and let users implement it themselves if needed.