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

round (and trunc, floor, ceil) not defined from Float64 or Float32 to BigInt #13367

Closed
carlobaldassi opened this issue Sep 29, 2015 · 1 comment

Comments

@carlobaldassi
Copy link
Member

I didn't see this reported elsewhere, so:

julia-0.4> round(BigInt, 2.5)
ERROR: MethodError: `trunc` has no method matching trunc(::Type{BigInt}, ::Float64)
Closest candidates are:
  trunc{T<:Integer}(::Type{T<:Integer}, ::Integer)
  trunc(::Type{Signed}, ::Float64)
  trunc(::Type{Unsigned}, ::Float64)
  ...
 in round at float.jl:177

There are definitions going from BigFloat to BigInt. Maybe we could use those, if implementing a direct route is unfeasible.

julia-0.4> round(BigInt, big"2.5")
2
@simonbyrne
Copy link
Contributor

Ha. I spent a lot of effort getting things correct the other way, but it didn't occur to me that we missed these.

It should be possible to do this directly using mpz_set_d without going via BigFloats.

carlobaldassi added a commit that referenced this issue Oct 1, 2015
skumagai pushed a commit to skumagai/julia that referenced this issue Oct 9, 2015
simonbyrne added a commit that referenced this issue Oct 31, 2015
(cherry picked from commit b31925c)
ref #13376
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

2 participants