diff --git a/modules/10_cpp14/src/digit_separators.cpp b/modules/10_cpp14/src/digit_separators.cpp index b3babbe..402a52d 100644 --- a/modules/10_cpp14/src/digit_separators.cpp +++ b/modules/10_cpp14/src/digit_separators.cpp @@ -4,17 +4,22 @@ namespace cpp14 { auto million() -> int { // TODO: Return 1'000'000 using digit separators - return 0; + return 1'000'000; } auto mask() -> std::uint32_t { // TODO: Return 0xFF00'00FF - return 0; + return 0xFF00'00FF; } auto bits_set() -> int { // TODO: Return population count of mask() - return 0; + const auto m = mask(); + auto count = 0; + for (auto i = 0; i < 32; i++) { + if (m & (1 << i)) ++count; + } + return count; } } // namespace cpp14