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

No methods for parse(ComplexN, "") #24704

Closed
ethomag opened this issue Nov 22, 2017 · 4 comments
Closed

No methods for parse(ComplexN, "") #24704

ethomag opened this issue Nov 22, 2017 · 4 comments

Comments

@ethomag
Copy link
Contributor

ethomag commented Nov 22, 2017

julia> parse(Complex128, "1.0+1.0im")
ERROR: MethodError: no method matching parse(::Type{Complex{Float64}}, ::String)

However, I can do:

julia> eval(parse("1.0+1.0im"))
1.0 + 1.0im
julia> typeof(ans)
Complex{Float64}

But, a bit awkward and will not give me immediate control of the resulting type.

Another - not related - strange thing which I've noticed with Complex is:

julia> one(im)
Complex(true,false)
julia> one(0+1im)
1 + 0im
julia> versioninfo()
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2680 v4@ 2.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)
@fredrikekre
Copy link
Member

First thing is duplicate of #22250

Another - not related - strange thing

What is strange about it?

@ethomag
Copy link
Contributor Author

ethomag commented Nov 22, 2017

First thing.
My apologies. Tried to search for a related issue, but could not find any. Thanks for pointing it out!

Second thing. I was just surprised by the result. I probably don't understand the subtle nuancies of the parsing of complex numbers or the Julia types. What surprises is:

Julias> typeof(im)
Complex{Bool}
Julias> typeof(1im)
Complex{Int64}

No issue here, just thought I spotted something previosly overlooked.

@ethomag
Copy link
Contributor Author

ethomag commented Nov 22, 2017

Since the only real issue was already reported and the second "issue" was not much of an issue. I close this.

@ethomag ethomag closed this as completed Nov 22, 2017
@fredrikekre
Copy link
Member

No worries.

typeof(1im)

Here we multiply an Int (1) with Bools (the true, and false inside im) so therefore the result is of type Int

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