forked from mpusz/mp-units
ratio_text improved to omit den == 1 for exp != 0
This commit is contained in:
@@ -29,21 +29,24 @@ namespace units::detail {
|
||||
template<typename Ratio>
|
||||
constexpr auto ratio_text()
|
||||
{
|
||||
if constexpr(Ratio::num != 1 || Ratio::den != 1 || Ratio::exp != 0) {
|
||||
if constexpr(Ratio::num == 1 && Ratio::den == 1 && Ratio::exp != 0) {
|
||||
return basic_fixed_string("\u00D7 10") + superscript<Ratio::exp>() + basic_fixed_string(" ");
|
||||
}
|
||||
else if constexpr(Ratio::num != 1 || Ratio::den != 1 || Ratio::exp != 0) {
|
||||
auto txt = basic_fixed_string("[") + regular<Ratio::num>();
|
||||
if constexpr(Ratio::den == 1) {
|
||||
if constexpr(Ratio::exp == 0) {
|
||||
return txt + basic_fixed_string("]");
|
||||
return txt + basic_fixed_string("] ");
|
||||
}
|
||||
else {
|
||||
return txt + basic_fixed_string(" \u00D7 10") + superscript<Ratio::exp>() +
|
||||
basic_fixed_string("]");
|
||||
basic_fixed_string("] ");
|
||||
}
|
||||
}
|
||||
else {
|
||||
return txt + basic_fixed_string("/") + regular<Ratio::den>() +
|
||||
basic_fixed_string(" \u00D7 10") + superscript<Ratio::exp>() +
|
||||
basic_fixed_string("]");
|
||||
basic_fixed_string("] ");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user