As in the topic title, I have found some strange behavior in Julia by exponentiating 10^large_number. In particular, I get negative numbers for some exponents. Also, the log function is treating these numbers as complex.
Any idea why is this happening?
Here below I report some results:
julia> 10^15 == 1e15
true
julia> 10^20 == 1e20
false
julia> 10^20 ≈ 1e20
false
julia> 10^31
-4570789518076018688
julia> 10^32
-8814407033341083648
julia> 10^33
4089650035136921600
julia> 10^31 > 0
false
julia> 10^33 > 0
true
julia> log(10^31)
ERROR: DomainError:
log will only return a complex result if called with a complex argument. Try log(complex(x)).
Stacktrace:
[1] nan_dom_err at ./math.jl:300 [inlined]
[2] log at ./math.jl:419 [inlined]
[3] log(::Int64) at ./math.jl:421
If I try the same on MATLAB I get
>> 10^32 == 1e32
ans =
logical
1
>> 10^32
ans =
1.0000e+32
I am on ubuntu 16.04 and Julia 0.6.3