- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.7k
 
Closed
Labels
mathsMathematical functionsMathematical functions
Description
hypot(::Int64, ::Float32) promotes the arguments and result to Float64, contrary to the behavior of promote, which gives Float32 in this case.
julia> hypot(1, 3.0f0)
3.1622776601683795
julia> promote(1, 3.0f0)
(1.0f0, 3.0f0)The culprits are the following method definitions:
Lines 798 to 799 in 71f68b4
| hypot(x::Number, y::Number) = _hypot(promote(float(x), y)...) | |
| hypot(x::Number, y::Number, xs::Number...) = _hypot(promote(float(x), y, xs...)) | 
Seems like this could be rewritten as follows for consistency with promote:
hypot(x::Number, y::Number) = _hypot(float.(promote(x, y))...)
hypot(x::Number, y::Number, xs::Number...) = _hypot(float.(promote(x, y, xs...)) Seelengrab, mikmoore and PallHaraldsson
Metadata
Metadata
Assignees
Labels
mathsMathematical functionsMathematical functions