diff --git a/include/units/core.h b/include/units/core.h index c1cdaed0..bd119469 100644 --- a/include/units/core.h +++ b/include/units/core.h @@ -3654,7 +3654,7 @@ namespace units dimensionless modf(const dimensionlessUnit x, dimensionlessUnit* intpart) noexcept { typename dimensionlessUnit::underlying_type intp; - dimensionlessUnit fracpart = std::modf(x.template to(), &intp); + dimensionlessUnit fracpart = dimensionless<>{std::modf(x.template to(), &intp)}; *intpart = intp; return fracpart; } diff --git a/unitTests/main.cpp b/unitTests/main.cpp index 8e516ecd..373d2c0c 100644 --- a/unitTests/main.cpp +++ b/unitTests/main.cpp @@ -4642,6 +4642,12 @@ TEST_F(UnitMath, modf) double umodfr1; decltype(uval) umodfr2; EXPECT_EQ(std::modf(uval.to(), &umodfr1), units::modf(uval, &umodfr2)); + EXPECT_EQ(umodfr1, umodfr2); + percent<> pval{202.5}; + double pmodfr1; + decltype(pval) pmodfr2; + EXPECT_EQ(std::modf(pval.to(), &pmodfr1), units::modf(pval, &pmodfr2)); + EXPECT_EQ(pmodfr1, pmodfr2); } TEST_F(UnitMath, exp2)