-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
convert(Unsigned, ::BigInt) and convert(Signed, ::BigInt) throw confusing error #19182
Comments
Is there a different use case where converting to |
It seems like we should define |
Seems wrong:
(Note also that there is no docstring for |
Yeah, |
I think a few places may use an implicit assumption that |
@simonbyrne, can you give an example? I would think that any such methods would need (and maybe already have) specialized |
One problem is that we'll get a bunch of method ambiguities that we'll need to resolve. e.g. |
I had a quick look in Base, and I didn't see any, so maybe it is okay (though packages may do this). The other issue is the use of |
Migrated from #15601 (comment):
The methods here (defined for
T<:Signed
andT<:Unsigned
) fail becausesizeof(Signed)
andsizeof(Unsigned)
are not defined, which are called in the casesT==Signed
andT==Unsigned
.It seems clear to me that we need specialized methods to handle
convert(Unsigned, ::BigInt)
andconvert(Signed, ::BigInt)
to fix the issue, but I'm not sure what the correct thing to do is here. Two obvious options:Try to convert to
Int
orUInt
, else throw anInexactError
if theBigInt
is too big (or has the wrong sign in the case ofUnsigned(big(-1))
).Always throw an
InexactError
(a better error than "argument is an abstract type").The text was updated successfully, but these errors were encountered: