-
Notifications
You must be signed in to change notification settings - Fork 21
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
Reversal of .bin() #49
Comments
The method x1 = Fxp(3.4)
x_bin = x1.bin() # or '0b' + x1.bin()
x2 = Fxp('0b' + x_bin, like=x1) # also works with fractional dot format If you don't want to keep x1 = Fxp(3.4)
x_bin = x1.bin(frac_dot=True)
x2 = Fxp('0b' + x_bin) In the last example |
Thanks for the quick response. The first example works in my case since the original will still be around so I'll go with that. It'd be a nice enhancement to go from just the output string on its own (as long as |
Yes, it would be good! |
Hi @francof2a , I am facing issue with fraction part using above method.
output is |
As you are using 2 bits for fractional part, 256.2 is rounded to 256.0. You need more fractional bits to get a fixed-point value closer to 256.2. With 2 bits for fractional part, the closer values to 256.2 are 256.0 and 256.25. If you use ret_int = Fxp(float_val, n_word=32, signed=True, n_frac=2, n_int=29, rounding='ceil') If you fix the ret_int = Fxp(float_val, n_word=32, signed=True)
|
Set value or create new Fxp from a binary string (issue #49).
solved in v0.4.9 |
I'm wondering if there is a way to revert calling
.bin()
. Something like:My use case is to convert into the notation, do some operations, then convert the result back over. I see the constructor can take in a binary value but it looks like it only takes in a "normal" python bit string. Is this possible currently?
The text was updated successfully, but these errors were encountered: