@@ -523,10 +523,10 @@ function rdiv_with_overflow(x::FD{T, f}, y::Integer) where {T<:Integer, f}
523
523
end
524
524
525
525
# Does not exist in Base.Checked, so just exists in this package.
526
- @doc """
526
+ """
527
527
FixedPointDecimals.ceil_with_overflow(x::FD)::Tuple{FD,Bool}
528
528
529
- Calculates the nearest integral value of the same type as x that is greater than or equal
529
+ Calculate the nearest integral value of the same type as x that is greater than or equal
530
530
to x, returning it and a boolean indicating whether overflow has occurred.
531
531
532
532
The overflow protection may impose a perceptible performance penalty.
@@ -546,10 +546,10 @@ function ceil_with_overflow(x::FD{T,f}) where {T<:Integer,f}
546
546
end
547
547
548
548
# Does not exist in Base.Checked, so just exists in this package.
549
- @doc """
549
+ """
550
550
FixedPointDecimals.floor_with_overflow(x::FD)::Tuple{FD,Bool}
551
551
552
- Calculates the nearest integral value of the same type as x that is less than or equal
552
+ Calculate the nearest integral value of the same type as x that is less than or equal
553
553
to x, returning it and a boolean indicating whether overflow has occurred.
554
554
555
555
The overflow protection may impose a perceptible performance penalty.
@@ -564,6 +564,16 @@ function floor_with_overflow(x::FD{T, f}) where {T, f}
564
564
return (reinterpret (FD{T, f}, backing), overflowed)
565
565
end
566
566
567
+ # Does not exist in Base.Checked, so just exists in this package.
568
+ """
569
+ FixedPointDecimals.round_with_overflow(x::FD, mode=RoundNearest)::Tuple{FD,Bool}
570
+
571
+ Calculate the nearest integral value of the same type as x, breaking ties using the
572
+ specified RoundingModes, returning it and a boolean indicating whether overflow has
573
+ occurred.
574
+
575
+ The overflow protection may impose a perceptible performance penalty.
576
+ """
567
577
round_with_overflow (fd:: FD , :: RoundingMode{:Up} ) = ceil_with_overflow (fd)
568
578
round_with_overflow (fd:: FD , :: RoundingMode{:Down} ) = floor_with_overflow (fd)
569
579
# trunc cannot overflow.
0 commit comments