@@ -27,6 +27,13 @@ module FixedPointDecimals
27
27
28
28
export FixedDecimal, RoundThrows
29
29
30
+ # (Re)export checked_* arithmetic functions
31
+ # - Defined in this package:
32
+ export checked_rdiv
33
+ # - Reexported from Base:
34
+ export checked_abs, checked_add, checked_cld, checked_div, checked_fld,
35
+ checked_mod, checked_mul, checked_neg, checked_rem, checked_sub
36
+
30
37
using Base: decompose, BitInteger
31
38
import Parsers
32
39
463
470
# We introduce a new function for this since Base.Checked only supports integers, and ints
464
471
# don't have a decimal division operation.
465
472
"""
466
- FixedPointDecimals.checked_decimal_division (x::FD, y::FD) -> FD
473
+ FixedPointDecimals.checked_rdiv (x::FD, y::FD) -> FD
467
474
468
475
Calculates `x / y`, checking for overflow errors where applicable.
469
476
@@ -472,11 +479,11 @@ The overflow protection may impose a perceptible performance penalty.
472
479
See also:
473
480
- `Base.checked_div` for truncating division.
474
481
"""
475
- checked_decimal_division (x:: FD , y:: FD ) = checked_decimal_division (promote (x, y)... )
476
- checked_decimal_division (x, y:: FD ) = checked_decimal_division (promote (x, y)... )
477
- checked_decimal_division (x:: FD , y) = checked_decimal_division (promote (x, y)... )
482
+ checked_rdiv (x:: FD , y:: FD ) = checked_rdiv (promote (x, y)... )
483
+ checked_rdiv (x, y:: FD ) = checked_rdiv (promote (x, y)... )
484
+ checked_rdiv (x:: FD , y) = checked_rdiv (promote (x, y)... )
478
485
479
- function checked_decimal_division (x:: FD{T,f} , y:: FD{T,f} ) where {T<: Integer ,f}
486
+ function checked_rdiv (x:: FD{T,f} , y:: FD{T,f} ) where {T<: Integer ,f}
480
487
powt = coefficient (FD{T, f})
481
488
quotient, remainder = fldmod (widemul (x. i, powt), y. i)
482
489
v = _round_to_nearest (quotient, remainder, y. i)
0 commit comments