Skip to content

Commit

Permalink
Use a local buffer in modf
Browse files Browse the repository at this point in the history
Fix #21591
  • Loading branch information
yuyichao committed Jul 17, 2017
1 parent f3915b1 commit b422a85
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -722,16 +722,16 @@ julia> modf(3.5)
"""
modf(x) = rem(x,one(x)), trunc(x)

const _modff_temp = Ref{Float32}()
function modf(x::Float32)
f = ccall((:modff,libm), Float32, (Float32,Ptr{Float32}), x, _modff_temp)
f, _modff_temp[]
temp = Ref{Float32}()
f = ccall((:modff, libm), Float32, (Float32, Ptr{Float32}), x, temp)
f, temp[]
end

const _modf_temp = Ref{Float64}()
function modf(x::Float64)
f = ccall((:modf,libm), Float64, (Float64,Ptr{Float64}), x, _modf_temp)
f, _modf_temp[]
temp = Ref{Float64}()
f = ccall((:modf, libm), Float64, (Float64, Ptr{Float64}), x, temp)
f, temp[]
end

@inline function ^(x::Float64, y::Float64)
Expand Down

0 comments on commit b422a85

Please sign in to comment.