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

Behavior of convert #292

Closed
rleegates opened this issue Aug 19, 2017 · 2 comments
Closed

Behavior of convert #292

rleegates opened this issue Aug 19, 2017 · 2 comments

Comments

@rleegates
Copy link

Is this behavior intended and wanted?

julia> convert(SVector{3,Float64},rand(SVector{3,Int}))
3-element StaticArrays.SVector{3,Float64}:
  5.00727e18
 -2.74974e18
 -1.37507e18
@c42f
Copy link
Member

c42f commented Aug 19, 2017

I think so. What is it that you find odd about this?

To expand out the behavior:

julia> v = rand(SVector{3,Int})
3-element SVector{3,Int64}:
 -8557660434043172070
  6108837298082502987
 -4334229712641791305

julia> convert(SVector{3,Float64}, v)
3-element SVector{3,Float64}:
 -8.55766e18
  6.10884e18
 -4.33423e18

We also have

julia> convert(Float64, rand(Int))
8.593402832541683e18

@andyferris
Copy link
Member

I think this is intentional.

It should also match the base array types:

julia> v = rand(Int, 3)
3-element Array{Int64,1}:
 6535532840261742524
 1289793510179775070
 4638388731794814437

julia> convert(Vector{Float64}, v)
3-element Array{Float64,1}:
 6.535532840261743e18
 1.289793510179775e18
 4.638388731794814e18

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

3 participants