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

widemul: document and export it? #6169

Closed
StefanKarpinski opened this issue Mar 14, 2014 · 3 comments
Closed

widemul: document and export it? #6169

StefanKarpinski opened this issue Mar 14, 2014 · 3 comments
Labels
needs decision A decision on this change is needed

Comments

@StefanKarpinski
Copy link
Member

The widemul function is pretty useful and we use it a fair bit in base. Should we commit to exporting and supporting it? I can't really think of any good reasons not to.

@JeffBezanson
Copy link
Member

Yes, let's. Maybe there should also be a widen function that gives you a value in a reasonably-larger type.

@JeffBezanson
Copy link
Member

And there is a decision on whether widen should be implemented as

widen(x) = convert(morebits(typeof(x)), x)

(morebits was added at some point)

@StefanKarpinski
Copy link
Member Author

I think we should rename morebits to widen and then have this:

widen(::Type{Int8}) = Int
widen(::Type{Int16}) = Int
widen(::Type{Int32}) = Int64
widen(::Type{Int64}) = Int128
widen(::Type{Int128}) = BigInt
widen(::Type{BigInt}) = BigInt

widen(::Type{Float16}) = Float32
widen(::Type{Float32}) = Float64
widen(::Type{Float64}) = BigFloat
widen(::Type{BigFloat}) = BigFloat

widen{T<:Number}(x::T) = convert(widen(T), x)

JeffBezanson added a commit that referenced this issue Mar 15, 2014
widen methods for Rational and Complex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs decision A decision on this change is needed
Projects
None yet
Development

No branches or pull requests

2 participants