diff --git a/Project.toml b/Project.toml index 2b2f8ef6..8ac63855 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Unitful" uuid = "1986cc42-f94f-5a68-af5c-568840ba703d" -version = "1.2.0" +version = "1.2.1" [deps] ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9" diff --git a/src/conversion.jl b/src/conversion.jl index 5288d70d..53961886 100644 --- a/src/conversion.jl +++ b/src/conversion.jl @@ -38,10 +38,9 @@ Find the conversion factor from unit `t` to unit `s`, e.g. `convfact(m,cm) = 0.0 end end - if denominator(ex) == 1 # Use an integer for conversion if the ratio is whole - ex = numerator(ex) # so that, e.g., uconvert(s, 1minute) = 60s + if ex isa Rational && denominator(ex) == 1 + ex = numerator(ex) end - a ≈ 1.0 ? (inex = 1) : (inex = a) y = inex * ex :($y) diff --git a/test/runtests.jl b/test/runtests.jl index 036518b0..b56985f0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -126,6 +126,8 @@ end # Issue 26 @unit altL "altL" altLiter 1000*cm^3 true @test convert(Float64, 1altL/cm^3) === 1000.0 + # Issue 327 + @test uconvert(u"√cm", 1u"√m") == 10u"√cm" end @testset "> Unitful ↔ unitful conversion" begin @testset ">> Numeric conversion" begin