Skip to content

Commit

Permalink
Merge pull request #544 from nebkat/patch-1
Browse files Browse the repository at this point in the history
feat: `ppm` parts per million
  • Loading branch information
mpusz authored Jan 20, 2024
2 parents 1df2cc7 + a62f061 commit 6e8a21a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/users_guide/framework_basics/dimensionless_quantities.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ with dimensionless quantities:
```cpp
inline constexpr struct percent : named_unit<"%", mag<ratio{1, 100}> * one> {} percent;
inline constexpr struct per_mille : named_unit<basic_symbol_text{"‰", "%o"}, mag<ratio(1, 1000)> * one> {} per_mille;
inline constexpr struct parts_per_million : named_unit<"ppm", mag<ratio(1, 1'000'000)> * one> {} parts_per_million;
inline constexpr auto ppm = parts_per_million;
```
Expand Down
2 changes: 2 additions & 0 deletions src/core/include/mp-units/unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,8 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Unit U>
// clang-format off
inline constexpr struct percent : named_unit<"%", mag<ratio{1, 100}> * one> {} percent;
inline constexpr struct per_mille : named_unit<basic_symbol_text{"", "%o"}, mag<ratio(1, 1000)> * one> {} per_mille;
inline constexpr struct parts_per_million : named_unit<"ppm", mag<ratio(1, 1'000'000)> * one> {} parts_per_million;
inline constexpr auto ppm = parts_per_million;
// clang-format on


Expand Down
1 change: 1 addition & 0 deletions test/static/unit_symbol_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ static_assert(unit_symbol(one) == "");
static_assert(unit_symbol(percent) == "%");
static_assert(unit_symbol(per_mille) == "‰");
static_assert(unit_symbol<unit_symbol_formatting{.encoding = ascii}>(per_mille) == "%o");
static_assert(unit_symbol(parts_per_million) == "ppm");
static_assert(unit_symbol(square(metre)) == "m²");
static_assert(unit_symbol<unit_symbol_formatting{.encoding = ascii}>(square(metre)) == "m^2");
static_assert(unit_symbol(cubic(metre)) == "m³");
Expand Down

0 comments on commit 6e8a21a

Please sign in to comment.