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

isinteger(::Normed) incorrect #120

Closed
cjdoris opened this issue May 11, 2019 · 1 comment
Closed

isinteger(::Normed) incorrect #120

cjdoris opened this issue May 11, 2019 · 1 comment

Comments

@cjdoris
Copy link

cjdoris commented May 11, 2019

The code currently assumes that the denominator is 2^f, which is not the case for Normed. e.g.

julia> isinteger(Normed{UInt8,7}(1))
false

I believe you need to change

isinteger(x::FixedPoint{T,f}) where {T,f} = (x.i&(1<<f-1)) == 0

to

isinteger(x::Fixed{T,f}) where {T,f} = (x.i&(1<<f-1)) == 0
isinteger(x::Normed{T,f}) where {T,f} = (x.i%(1<<f-1)) == 0
@cjdoris cjdoris changed the title isinteger(::Normed) incorrect isinteger(::Normed) incorrect May 11, 2019
@johnnychen94
Copy link
Collaborator

This looks good (though I don't quite understand the magic shifting operations here), could you open a PR on this?

Thanks

johnnychen94 added a commit to johnnychen94/FixedPointNumbers.jl that referenced this issue May 15, 2019
fixes JuliaMath#120 : `isinteger(1N0f8)` should be true
johnnychen94 added a commit to johnnychen94/FixedPointNumbers.jl that referenced this issue May 15, 2019
fixes JuliaMath#120 : `isinteger(1N0f8)` should be true
@kimikage kimikage mentioned this issue Jan 12, 2020
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.

2 participants