diff --git a/example/foot_pound_second.cpp b/example/foot_pound_second.cpp index b14576b4..13ec8c39 100644 --- a/example/foot_pound_second.cpp +++ b/example/foot_pound_second.cpp @@ -58,7 +58,8 @@ struct Ship { template auto fmt_line(const Q& q) { - return MP_UNITS_STD_FMT::format("{:22}", q) + (MP_UNITS_STD_FMT::format(",{:20}", value_cast(q)) + ...); + return MP_UNITS_STD_FMT::format("{:22:N[.2f]}", q) + + (MP_UNITS_STD_FMT::format(",{:20:N[.2f]}", value_cast(q)) + ...); } // Print the ship details in the units as defined in the Ship struct, in other si::imperial units, and in SI diff --git a/example/glide_computer_lib/glide_computer_lib.cpp b/example/glide_computer_lib/glide_computer_lib.cpp index b286dde6..f82d0d4c 100644 --- a/example/glide_computer_lib/glide_computer_lib.cpp +++ b/example/glide_computer_lib/glide_computer_lib.cpp @@ -82,7 +82,7 @@ void print(std::string_view phase_name, timestamp start_ts, const glide_computer const glide_computer::flight_point& new_point) { std::cout << MP_UNITS_STD_FMT::format( - "| {:<12} | {:>9:N[.1]} (Total: {:>9:N[.1]}) | {:>8:N[.1]} (Total: {:>8:N[.1]}) | {:>7:N[.0]} ({:>6:N[.0]}) |\n", + "| {:<12} | {:>9:N[.1]} (Total: {:>9:N[.1]}) | {:>8:N[.1]} (Total: {:>8:N[.1]}) | {:>7:N[.0f]} ({:>6:N[.0f]}) |\n", phase_name, value_cast(new_point.ts - point.ts), value_cast(new_point.ts - start_ts), new_point.dist - point.dist, new_point.dist, new_point.alt - point.alt, new_point.alt); } diff --git a/example/spectroscopy_units.cpp b/example/spectroscopy_units.cpp index 78869409..531c1af1 100644 --- a/example/spectroscopy_units.cpp +++ b/example/spectroscopy_units.cpp @@ -55,8 +55,9 @@ template T1, QuantityOf T2, QuantityOf< QuantityOf T4, QuantityOf T5> void print_line(const std::tuple& t) { - std::cout << MP_UNITS_STD_FMT::format("| {:<15} | {:<15} | {:<15} | {:<15} | {:<15} |\n", std::get<0>(t), - std::get<1>(t), std::get<2>(t), std::get<3>(t), std::get<4>(t)); + std::cout << MP_UNITS_STD_FMT::format( + "| {:<15:N[.6]} | {:<15:N[.6]} | {:<15:N[.6]} | {:<15:N[.6]} | {:<15:N[.6]} |\n", std::get<0>(t), std::get<1>(t), + std::get<2>(t), std::get<3>(t), std::get<4>(t)); } // prints quantities in semi-SI units @@ -65,9 +66,9 @@ template T1, QuantityOf T2, QuantityOf< QuantityOf T4, QuantityOf T5> void print_line_si(const std::tuple& t) { - std::cout << MP_UNITS_STD_FMT::format("| {:<15} | {:<15} | {:<15} | {:<15} | {:<15} |\n", std::get<0>(t).in(eV), - std::get<1>(t).in(one / cm), std::get<2>(t).in(THz), std::get<3>(t).in(K), - std::get<4>(t).in(um)); + std::cout << MP_UNITS_STD_FMT::format( + "| {:<15:N[.6]} | {:<15:N[.6]} | {:<15:N[.6]} | {:<15:N[.6]} | {:<15:N[.6]} |\n", std::get<0>(t).in(eV), + std::get<1>(t).in(one / cm), std::get<2>(t).in(THz), std::get<3>(t).in(K), std::get<4>(t).in(um)); } int main() diff --git a/example/unmanned_aerial_vehicle.cpp b/example/unmanned_aerial_vehicle.cpp index e2d25710..e520fd4d 100644 --- a/example/unmanned_aerial_vehicle.cpp +++ b/example/unmanned_aerial_vehicle.cpp @@ -158,10 +158,10 @@ int main() unmanned_aerial_vehicle uav; uav.take_off(mean_sea_level + 6'000 * ft); uav.current(mean_sea_level + 10'000 * ft); - std::cout << MP_UNITS_STD_FMT::format("hal = {}\n", uav.hal()); + std::cout << MP_UNITS_STD_FMT::format("hal = {::N[.2f]}\n", uav.hal()); msl_altitude ground_level = mean_sea_level + 123 * m; - std::cout << MP_UNITS_STD_FMT::format("agl = {}\n", uav.current() - ground_level); + std::cout << MP_UNITS_STD_FMT::format("agl = {::N[.2f]}\n", uav.current() - ground_level); struct waypoint { std::string name; @@ -170,6 +170,6 @@ int main() }; waypoint wpt = {"EPPR", {54.24772_N, 18.6745_E}, mean_sea_level + 16. * ft}; - std::cout << MP_UNITS_STD_FMT::format("{}: {} {}, {::N[.2]}, {::N[.2]}\n", wpt.name, wpt.pos.lat, wpt.pos.lon, + std::cout << MP_UNITS_STD_FMT::format("{}: {} {}, {::N[.2f]}, {::N[.2f]}\n", wpt.name, wpt.pos.lat, wpt.pos.lon, wpt.msl_alt, to_hae(wpt.msl_alt, wpt.pos)); }