Skip to content

Commit

Permalink
Add missing docstring for round_with_overflow (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly authored Feb 20, 2025
1 parent 26c0a19 commit f45fb68
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/FixedPointDecimals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,10 @@ function rdiv_with_overflow(x::FD{T, f}, y::Integer) where {T<:Integer, f}
end

# Does not exist in Base.Checked, so just exists in this package.
@doc """
"""
FixedPointDecimals.ceil_with_overflow(x::FD)::Tuple{FD,Bool}
Calculates the nearest integral value of the same type as x that is greater than or equal
Calculate the nearest integral value of the same type as x that is greater than or equal
to x, returning it and a boolean indicating whether overflow has occurred.
The overflow protection may impose a perceptible performance penalty.
Expand All @@ -546,10 +546,10 @@ function ceil_with_overflow(x::FD{T,f}) where {T<:Integer,f}
end

# Does not exist in Base.Checked, so just exists in this package.
@doc """
"""
FixedPointDecimals.floor_with_overflow(x::FD)::Tuple{FD,Bool}
Calculates the nearest integral value of the same type as x that is less than or equal
Calculate the nearest integral value of the same type as x that is less than or equal
to x, returning it and a boolean indicating whether overflow has occurred.
The overflow protection may impose a perceptible performance penalty.
Expand All @@ -564,6 +564,16 @@ function floor_with_overflow(x::FD{T, f}) where {T, f}
return (reinterpret(FD{T, f}, backing), overflowed)
end

# Does not exist in Base.Checked, so just exists in this package.
"""
FixedPointDecimals.round_with_overflow(x::FD, mode=RoundNearest)::Tuple{FD,Bool}
Calculate the nearest integral value of the same type as x, breaking ties using the
specified RoundingModes, returning it and a boolean indicating whether overflow has
occurred.
The overflow protection may impose a perceptible performance penalty.
"""
round_with_overflow(fd::FD, ::RoundingMode{:Up}) = ceil_with_overflow(fd)
round_with_overflow(fd::FD, ::RoundingMode{:Down}) = floor_with_overflow(fd)
# trunc cannot overflow.
Expand Down

2 comments on commit f45fb68

@NHDaly
Copy link
Member Author

@NHDaly NHDaly commented on f45fb68 Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

Release Notes:

New Library functions

  • FixedPointDecimals.floor_with_overflow(x::FD)::Tuple{FD,Bool}
    
  • FixedPointDecimals.ceil_with_overflow(x::FD)::Tuple{FD,Bool}
    
  • FixedPointDecimals.round_with_overflow(x::FD, [rounding_mode])::Tuple{FD,Bool}
    

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/125467

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.3 -m "<description of version>" f45fb681759049ad6cb6535900cfa55a0f625d96
git push origin v0.6.3

Please sign in to comment.