diff --git a/src/quantities.jl b/src/quantities.jl index b6b4a422..cfd2a863 100644 --- a/src/quantities.jl +++ b/src/quantities.jl @@ -119,6 +119,7 @@ end Base.mod2pi(x::DimensionlessQuantity) = mod2pi(uconvert(NoUnits, x)) Base.mod2pi(x::AbstractQuantity{S, NoDims, <:Units{(Unitful.Unit{:Degree, NoDims}(0, 1//1),), NoDims}}) where S = mod(x, 360°) +Base.modf(x::DimensionlessQuantity) = modf(uconvert(NoUnits, x)) # Addition / subtraction for op in [:+, :-] diff --git a/test/runtests.jl b/test/runtests.jl index b3afd6c9..7a6a301b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -630,6 +630,7 @@ end @test mod(1hr+3minute+5s, 24s) == 17s @test mod2pi(360°) === 0° # 2pi is 360° @test mod2pi(0.5pi*u"m/dm") ≈ pi # just testing the dimensionless fallback + @test modf(2.5rad) === (0.5, 2.0) @test @inferred(inv(s)) === s^-1 @test inv(ContextUnits(m,km)) === ContextUnits(m^-1,km^-1) @test inv(FixedUnits(m)) === FixedUnits(m^-1)