Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializing Fxp with hex if hex contains 'b' init crashes #15

Closed
FredKellerman opened this issue Aug 7, 2020 · 4 comments
Closed

Initializing Fxp with hex if hex contains 'b' init crashes #15

FredKellerman opened this issue Aug 7, 2020 · 4 comments

Comments

@FredKellerman
Copy link

FredKellerman commented Aug 7, 2020

Hi Franco, Sorry about this but I have found if a 'b' hex char appears the string appears to be interpreted as binary and then it will crash if the digits are not 0 or 1

You can reproduce the error with this:

f = Fxp('0xb', True, 10, 4)
@narendiran1996
Copy link

I too had similar issue.
Solved it by changing the following line in ~/.local/lib/python3.8/site-packages/fxpmath/utils.py in the str2num function.
if base == 2 or 'b' in x: to if base == 2 or 'b' in x[:2]:

Location in github sources util.py - Line number 154.

francof2a added a commit that referenced this issue Nov 12, 2020
* hex representations support padding.
* fix bug with 'b' in hex string (issue #15).
* fix inaccuracy word in status (issue #16).
* fix __pow__ method (issue #17).
* fix bug that only store imaginary part in complex assignement by indexing (issue #19).
@francof2a
Copy link
Owner

Hello!
This issue is resolved now. Thank you!

@FredKellerman
Copy link
Author

Thank you!

@narendiran1996
Copy link

Thank You.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants