@@ -27,7 +27,7 @@ module FixedPointDecimals
27
27
28
28
export FixedDecimal, RoundThrows
29
29
30
- using Base: decompose, BitInteger
30
+ using Base: decompose, BitInteger, @pure
31
31
32
32
# floats that support fma and are roughly IEEE-like
33
33
const FMAFloat = Union{Float16, Float32, Float64, BigFloat}
@@ -79,8 +79,8 @@ struct FixedDecimal{T <: Integer, f} <: Real
79
79
i:: T
80
80
81
81
# inner constructor
82
- # This function is marked as `Base. @pure`. It does not have or depend on any side-effects.
83
- Base . @pure function Base. reinterpret (:: Type{FixedDecimal{T, f}} , i:: Integer ) where {T, f}
82
+ # This function is marked as `@pure`. It does not have or depend on any side-effects.
83
+ @pure function Base. reinterpret (:: Type{FixedDecimal{T, f}} , i:: Integer ) where {T, f}
84
84
n = max_exp10 (T)
85
85
if f >= 0 && (n < 0 || f <= n)
86
86
new {T, f} (i % T)
@@ -115,15 +115,15 @@ Base.:+(x::FD{T, f}, y::FD{T, f}) where {T, f} = reinterpret(FD{T, f}, x.i+y.i)
115
115
Base.:- (x:: FD{T, f} , y:: FD{T, f} ) where {T, f} = reinterpret (FD{T, f}, x. i- y. i)
116
116
117
117
# wide multiplication
118
- Base . @pure function Base. widemul (x:: FD{<:Any, f} , y:: FD{<:Any, g} ) where {f, g}
118
+ @pure function Base. widemul (x:: FD{<:Any, f} , y:: FD{<:Any, g} ) where {f, g}
119
119
i = widemul (x. i, y. i)
120
120
reinterpret (FD{typeof (i), f + g}, i)
121
121
end
122
- Base . @pure function Base. widemul (x:: FD{T, f} , y:: Integer ) where {T, f}
122
+ @pure function Base. widemul (x:: FD{T, f} , y:: Integer ) where {T, f}
123
123
i = widemul (x. i, y)
124
124
reinterpret (FD{typeof (i), f}, i)
125
125
end
126
- Base . @pure Base. widemul (x:: Integer , y:: FD ) = widemul (y, x)
126
+ @pure Base. widemul (x:: Integer , y:: FD ) = widemul (y, x)
127
127
128
128
"""
129
129
_round_to_even(quotient, remainder, divisor)
@@ -333,7 +333,7 @@ Base.promote_rule(::Type{<:FD}, ::Type{Rational{TR}}) where {TR} = Rational{TR}
333
333
334
334
# TODO : decide if these are the right semantics;
335
335
# right now we pick the bigger int type and the bigger decimal point
336
- Base . @pure function Base. promote_rule (:: Type{FD{T, f}} , :: Type{FD{U, g}} ) where {T, f, U, g}
336
+ @pure function Base. promote_rule (:: Type{FD{T, f}} , :: Type{FD{U, g}} ) where {T, f, U, g}
337
337
FD{promote_type (T, U), max (f, g)}
338
338
end
339
339
@@ -480,7 +480,7 @@ NOTE: This function is expensive, since it contains a while-loop, but it is actu
480
480
This function does not have or depend on any side-effects.
481
481
"""
482
482
function max_exp10 (:: Type{T} ) where {T <: Integer }
483
- # This function is marked as `Base. @pure`. Even though it does call some generic
483
+ # This function is marked as `@pure`. Even though it does call some generic
484
484
# functions, they are all simple methods that should be able to be evaluated as
485
485
# constants. This function does not have or depend on any side-effects.
486
486
516
516
Compute `10^f` as an Integer without overflow. Note that overflow will not occur for any
517
517
constructable `FD{T, f}`.
518
518
"""
519
- Base . @pure coefficient (:: Type{FD{T, f}} ) where {T, f} = T (10 )^ f
520
- Base . @pure coefficient (fd:: FD{T, f} ) where {T, f} = coefficient (FD{T, f})
519
+ @pure coefficient (:: Type{FD{T, f}} ) where {T, f} = T (10 )^ f
520
+ @pure coefficient (fd:: FD{T, f} ) where {T, f} = coefficient (FD{T, f})
521
521
value (fd:: FD ) = fd. i
522
522
523
523
# for generic hashing
0 commit comments