JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.43k stars 5.45k forks source link

misbehaviour of sqrt(complex(x)) #3686

Closed Ph0non closed 11 years ago

Ph0non commented 11 years ago

Thera is some strange misbehaviour of sqrt on a machine with win x64

e.g. sqrt(complex(0,2)) returns 3.355… + 2.980…e-8im

or another example

sqrt(complex(-1,0)) returns 0.0 Inf

stevengj commented 11 years ago

Works on GNU/Linux; may be specific to the Windows build.

Ph0non commented 11 years ago

mlubin on irc confirm that it works correct an linux. The build is from source (11. July) with mingw32/msys on the same machine.

Keno commented 11 years ago

Probably ABI related. I.e. will be fixed by #3466

vharavy commented 11 years ago

Seems, that problem is with ldexp function that is called from sqrt:

julia> ldexp(1.0, 2)
4.294967296e9

julia> ldexp(1.0, 2)
Inf

It most likely not related to #3466 because ldexp does not accept any structures.

stevengj commented 11 years ago

May be a problem with openlibm, as that is where the scalbn function (called by ldexp) lives? (If you run deps/openlibm/test/test-double, does it report any failures with scalbn?)

vtjnash commented 11 years ago

fixed in https://github.com/JuliaLang/openlibm/commit/0cd232d8cf5f4d891b187133564bd4d3e3c2fc4e

Ph0non commented 11 years ago

building a new clone fails at win x64

cp: cannot stat 'openlib/libopenlibm.a': No such file or directory

i‘m confused. cloning to a new local rep give this error, only updating existing rep works fine, but not all files are updated (especially deps/openlibm)

git hash b76cffc6d makes the trouble at building