@@ -27,7 +27,7 @@ module FixedPointDecimals
2727
2828export FixedDecimal, RoundThrows
2929
30- using Base: decompose, BitInteger, @pure
30+ using Base: decompose, BitInteger
3131
3232# floats that support fma and are roughly IEEE-like
3333const FMAFloat = Union{Float16, Float32, Float64, BigFloat}
@@ -79,8 +79,7 @@ struct FixedDecimal{T <: Integer, f} <: Real
7979 i:: T
8080
8181 # 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}
8483 n = max_exp10 (T)
8584 if f >= 0 && (n < 0 || f <= n)
8685 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)
115114Base.:- (x:: FD{T, f} , y:: FD{T, f} ) where {T, f} = reinterpret (FD{T, f}, x. i- y. i)
116115
117116# 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}
119118 i = widemul (x. i, y. i)
120119 reinterpret (FD{typeof (i), f + g}, i)
121120end
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}
123122 i = widemul (x. i, y)
124123 reinterpret (FD{typeof (i), f}, i)
125124end
126- @pure Base. widemul (x:: Integer , y:: FD ) = widemul (y, x)
125+ Base. widemul (x:: Integer , y:: FD ) = widemul (y, x)
127126
128127"""
129128 _round_to_even(quotient, remainder, divisor)
@@ -333,7 +332,7 @@ Base.promote_rule(::Type{<:FD}, ::Type{Rational{TR}}) where {TR} = Rational{TR}
333332
334333# TODO : decide if these are the right semantics;
335334# 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}
337336 FD{promote_type (T, U), max (f, g)}
338337end
339338
@@ -504,16 +503,14 @@ for T in Base.BitInteger_types
504503 @eval max_exp10 (:: Type{$T} ) = $ (max_exp10 (T))
505504end
506505
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.
509506"""
510507 coefficient(::Type{FD{T, f}}) -> T
511508
512509Compute `10^f` as an Integer without overflow. Note that overflow will not occur for any
513510constructable `FD{T, f}`.
514511"""
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})
517514value (fd:: FD ) = fd. i
518515
519516# for generic hashing
0 commit comments