@@ -27,7 +27,7 @@ module FixedPointDecimals
27
27
28
28
export FixedDecimal, RoundThrows
29
29
30
- using Base: decompose, BitInteger, @pure
30
+ using Base: decompose, BitInteger
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,7 @@ struct FixedDecimal{T <: Integer, f} <: Real
79
79
i:: T
80
80
81
81
# inner constructor
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}
82
+ function Base. reinterpret (:: Type{FixedDecimal{T, f}} , i:: Integer ) where {T, f}
84
83
n = max_exp10 (T)
85
84
if f >= 0 && (n < 0 || f <= n)
86
85
new {T, f} (i % T)
@@ -115,15 +114,15 @@ Base.:+(x::FD{T, f}, y::FD{T, f}) where {T, f} = reinterpret(FD{T, f}, x.i+y.i)
115
114
Base.:- (x:: FD{T, f} , y:: FD{T, f} ) where {T, f} = reinterpret (FD{T, f}, x. i- y. i)
116
115
117
116
# wide multiplication
118
- @pure function Base. widemul (x:: FD{<:Any, f} , y:: FD{<:Any, g} ) where {f, g}
117
+ function Base. widemul (x:: FD{<:Any, f} , y:: FD{<:Any, g} ) where {f, g}
119
118
i = widemul (x. i, y. i)
120
119
reinterpret (FD{typeof (i), f + g}, i)
121
120
end
122
- @pure function Base. widemul (x:: FD{T, f} , y:: Integer ) where {T, f}
121
+ function Base. widemul (x:: FD{T, f} , y:: Integer ) where {T, f}
123
122
i = widemul (x. i, y)
124
123
reinterpret (FD{typeof (i), f}, i)
125
124
end
126
- @pure Base. widemul (x:: Integer , y:: FD ) = widemul (y, x)
125
+ Base. widemul (x:: Integer , y:: FD ) = widemul (y, x)
127
126
128
127
"""
129
128
_round_to_even(quotient, remainder, divisor)
@@ -333,7 +332,7 @@ Base.promote_rule(::Type{<:FD}, ::Type{Rational{TR}}) where {TR} = Rational{TR}
333
332
334
333
# TODO : decide if these are the right semantics;
335
334
# right now we pick the bigger int type and the bigger decimal point
336
- @pure function Base. promote_rule (:: Type{FD{T, f}} , :: Type{FD{U, g}} ) where {T, f, U, g}
335
+ function Base. promote_rule (:: Type{FD{T, f}} , :: Type{FD{U, g}} ) where {T, f, U, g}
337
336
FD{promote_type (T, U), max (f, g)}
338
337
end
339
338
@@ -504,16 +503,14 @@ for T in Base.BitInteger_types
504
503
@eval max_exp10 (:: Type{$T} ) = $ (max_exp10 (T))
505
504
end
506
505
507
- # coefficient is marked pure. This is needed to ensure that the result is always available
508
- # at compile time, and can therefore be used when optimizing mathematical operations.
509
506
"""
510
507
coefficient(::Type{FD{T, f}}) -> T
511
508
512
509
Compute `10^f` as an Integer without overflow. Note that overflow will not occur for any
513
510
constructable `FD{T, f}`.
514
511
"""
515
- @pure coefficient (:: Type{FD{T, f}} ) where {T, f} = T (10 )^ f
516
- @pure coefficient (fd:: FD{T, f} ) where {T, f} = coefficient (FD{T, f})
512
+ coefficient (:: Type{FD{T, f}} ) where {T, f} = T (10 )^ f
513
+ coefficient (fd:: FD{T, f} ) where {T, f} = coefficient (FD{T, f})
517
514
value (fd:: FD ) = fd. i
518
515
519
516
# for generic hashing
0 commit comments