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

mixing Fixed and Normed #126

Closed
rapus95 opened this issue Jun 16, 2019 · 2 comments · Fixed by #207
Closed

mixing Fixed and Normed #126

rapus95 opened this issue Jun 16, 2019 · 2 comments · Fixed by #207

Comments

@rapus95
Copy link

rapus95 commented Jun 16, 2019

I recently had to add several differences of N0f8 values to finally take the abs of it. Thus I tried to do

#a,b of type N0f8
x = zero(Q7f8)
x += a - b

which probably would've failed due to the difference being negative and thus not representable.
Thus the next step for me would've been to convert a,b to Q7f8 which didn't work.

Thus my question: Is there any reason why we can't mix up these types?
btw promote(N0f8(.5), Q7f8(.5)) throws an error.

@johnnychen94
Copy link
Collaborator

johnnychen94 commented Aug 1, 2019

An interesting issue related to this is:

julia> promote_type(UInt8, Int8)
UInt8

julia> UInt8(1) - Int8(2)
0xff

Update: detailed discussion goes in JuliaLang/julia#9292

@timholy
Copy link
Member

timholy commented Aug 12, 2019

We should define promotions that make sense. Care to give it a crack?

In practice, the two number types are slightly different: N1f7 is scaled by 1/127, but Q0f7 is scaled by 1/128. What this means is that arithmetic may be faster if you first convert everything to Float32, and then store the final result in whatever format you want.

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