Andreas gave you the correct answer as it happened: 

issue 3101 <https://github.com/JuliaLang/julia/issues/3101> and on 
2013-May-16 
<https://github.com/JuliaLang/julia/commit/dc6992d2571fa2eba32fe78b957f27018ffb85c0>

Later that year, responding to issue 4465 
<https://github.com/JuliaLang/julia/issues/4465>
function hypot(x::Real, y::Real) ...
become
hypot(x::Real, y::Real) = hypot(promote(x,y)...)
function hypot{T<:Real}(x::T, y::T) ...

sometime after that, there were specializations that called the C library 
hypot
hypot(x::Float32, y::Float64), hypot(x::Float64, y:Float32)
which, as more megawonder mathy merrymaking took hold, were removed

I surmise that you are observing an erstwhile expressive application of 
unity, a now vestigial subexpression.
afaict, with the successive improvements to hypot now in place, (if x == 0 
return(y) else r = y/x) is now safe



On Sunday, March 27, 2016 at 12:35:59 PM UTC-4, feza wrote:
>
> I don't think that's the reason, since:
> ``` 
> if x == 0                                                                 
>                 
>          r = y/one(x)   # Why not just return y?
> ```
> This can only happen if  x = 0 or x = 0.0 and y = NaN      or      x = 0 
> or x = 0.0 and  y = 0 or y = 0.0
>
> hypot(2,0)
> 2.0
>
> hypot(0,2)
> 2.0
>
> hypot(0,0)
> 0
>
> hypot(0,0.0)
> 0.0
>
>
>
> On Sunday, March 27, 2016 at 9:41:12 AM UTC-4, Andreas Noack wrote:
>>
>> It's to ensure that the return type doesn't depend on the value of x. If 
>> x and y are integers then the return type of hypot1 will be Int if x==0 and 
>> Float64 otherwise.
>>
>>

Reply via email to