Hello, i am getting this behavior:
julia> a = 1.5 + 3//4im
1.5 - 0.75im
What I expected was:
julia> a = 1.5 + 3//4im
1.5 + 0.75im
Can any one tell me why?
Hello, i am getting this behavior:
julia> a = 1.5 + 3//4im
1.5 - 0.75im
What I expected was:
julia> a = 1.5 + 3//4im
1.5 + 0.75im
Can any one tell me why?
try
julia> a = 1.5 + (3//4)im
Multiplication by juxtaposition has higher precedence than //
, so what you’re actually computing is 3//(4im)
. You can see how an expression is lowered for example with:
julia> Meta.@lower 3//4im
:($(Expr(:thunk, CodeInfo(
1 ─ %1 = 4im
│ %2 = 3 // %1
└── return %2
))))
And by /
, it turns out. So you can write this, which is nice to know!
julia> 1/2π == 1/(2π)
true
Also:
julia> 1/2*π == 0.5π
true
julia> 1/2big(π) == 1/(2*big(π))
true
Thank you. I can sleep in peace today