Skip to content

Commit

Permalink
Merge pull request #177 from LilithHafner/patch-1
Browse files Browse the repository at this point in the history
Fix typo in rounding
  • Loading branch information
staticfloat authored Aug 31, 2023
2 parents 4416838 + 1bb0f70 commit 87ba8de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/math/prearith/floorceiltrunc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ function round(x::DoubleFloat{T}, ::RoundingMode{:Down}) where {T<:IEEEFloat}
return floor(x)
end

function round(x::DoubleFloat{T}, ::RoundingMode{:RoundToZero}) where {T<:IEEEFloat}
function round(x::DoubleFloat{T}, ::RoundingMode{:ToZero}) where {T<:IEEEFloat}
return isnegative(x) ? ceil(x) : floor(x)
end

function round(x::DoubleFloat{T}, ::RoundingMode{:RoundFromZero}) where {T<:IEEEFloat}
function round(x::DoubleFloat{T}, ::RoundingMode{:FromZero}) where {T<:IEEEFloat}
return isnegative(x) ? floor(x) : ceil(x)
end

Expand Down
3 changes: 3 additions & 0 deletions test/prearith.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ end
@test 6.0 == @eval tld($T(pi), 0.5)
end

@testset "#176" begin
@test round(Double16(pi), RoundToZero) == 3
end

0 comments on commit 87ba8de

Please sign in to comment.