Skip to content

Multiplication by Ufixed{UInt8, 8}(1) is no longer an identity #34

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

Closed
cstjean opened this issue Oct 31, 2015 · 5 comments
Closed

Multiplication by Ufixed{UInt8, 8}(1) is no longer an identity #34

cstjean opened this issue Oct 31, 2015 · 5 comments

Comments

@cstjean
Copy link

cstjean commented Oct 31, 2015

Did FixedPoint arithmetic change recently? I'm fairly certain that this

using FixedPointNumbers: UFixed
a = UFixed{UInt8, 8}(1.0)
b = UFixed{UInt8, 8}(0.65)
@show a b a*b
> a = UFixed8(1.0)
> b = UFixed8(0.651)
> a * b = UFixed8(0.647)

was not the case until I Pkg.updated today. It's a bit of a problem for my use case...

@timholy
Copy link
Member

timholy commented Oct 31, 2015

Did FixedPoint arithmetic change recently?

Yes, see #27. Aside from a general cleanup, it brought FixedPointNumbers into alignment with the rest of julia 0.4 in making them closed under arithmetic operations.

But the problem you've noticed is Not Good. I've got major deadlines for the next 5 days, so I sure hope someone can help deal with this and tag a new release. CC @vchuravy?

@vchuravy
Copy link
Collaborator

I see what is wrong... the root of the issue is the problem I am having in #32.

So UFixed8(1) = 0xFF and widemul(0xFF, 0xFF) = 0x000000000000fe01, shift that back 8 bits and you get 0xFE01 even with the additional rounding that we do in the multiplication you do not get back to one. I will look into this tomorrow morning and in the worst case restore the old definition (, but still making it closed).

@cstjean
Copy link
Author

cstjean commented Oct 31, 2015

Thank you. I think #27 was a great step forward, I hope the issue can be fixed!

@vchuravy
Copy link
Collaborator

Yeah the issue is more or less of [me] wanting to define UFixed numbers as traditional FixedPoint numbers that are just unsigned, while they are not :) and me realizing that after the PR went through.

@timholy
Copy link
Member

timholy commented Oct 31, 2015

If they need to be split out with different naming, I'm fine with that. I think we went through some discussion along these lines when they were first added, but that can be revisted.

This was referenced Nov 2, 2015
@timholy timholy closed this as completed in 8302a1b Nov 3, 2015
timholy added a commit that referenced this issue Nov 3, 2015
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

Successfully merging a pull request may close this issue.

3 participants