diff --git a/CMakeLists.txt b/CMakeLists.txt index fed855f..4913ed7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ set(SNITCH_WITH_MULTITHREADING ON CACHE BOOL "Make the testing fram set(SNITCH_WITH_TIMINGS ON CACHE BOOL "Measure the time taken by each test case -- disable to speed up tests.") set(SNITCH_WITH_SHORTHAND_MACROS ON CACHE BOOL "Use short names for test macros -- disable if this causes conflicts.") set(SNITCH_CONSTEXPR_FLOAT_USE_BITCAST ON CACHE BOOL "Use std::bit_cast if available to implement exact constexpr float-to-string conversion.") -set(SNITCH_APPEND_TO_CHARS ON CACHE BOOL "Use std::to_char for string conversions -- disable for greater compatability with a slight performance cost.") +set(SNITCH_APPEND_TO_CHARS ON CACHE BOOL "Use std::to_chars for string conversions -- disable for greater compatability with a slight performance cost.") set(SNITCH_DEFAULT_WITH_COLOR ON CACHE BOOL "Enable terminal colors by default -- can also be controlled by command line interface.") set(SNITCH_DECOMPOSE_SUCCESSFUL_ASSERTIONS OFF CACHE BOOL "Enable expression decomposition even for successful assertions -- more expensive.") set(SNITCH_WITH_ALL_REPORTERS ON CACHE BOOL "Allow all built-in reporters to be selected from the command line -- disable for faster compilation.") diff --git a/include/snitch/snitch_append.hpp b/include/snitch/snitch_append.hpp index 7914b54..1a0f4f7 100644 --- a/include/snitch/snitch_append.hpp +++ b/include/snitch/snitch_append.hpp @@ -153,7 +153,7 @@ set_precision(signed_fixed_data fd, std::size_t p) noexcept { base_digits -= 1u; } else { fd.digits = round_half_to_even(fd.digits, only_zero); - base_digits = num_digits(static_cast(fd.digits)); + base_digits = num_digits<10>(static_cast(fd.digits)); } fd.exponent += 1; diff --git a/meson_options.txt b/meson_options.txt index a79ce10..097599d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -19,7 +19,7 @@ option('with_multithreading' ,type: 'boolean', value: true, descript option('with_timings' ,type: 'boolean' ,value: true, description: 'Measure the time taken by each test case -- disable to speed up tests.') option('with_shorthand_macros' ,type: 'boolean' ,value: true, description: 'Use short names for test macros -- disable if this causes conflicts.') option('constexpr_float_use_bitcast' ,type: 'boolean' ,value: true, description: 'Use std::bit_cast if available to implement exact constexpr float-to-string conversion.') -option('snitch_append_to_chars' ,type: 'boolean' ,value: true, description: 'Use std::to_char for string conversions -- disable for greater compatability with a slight performance cost.') +option('snitch_append_to_chars' ,type: 'boolean' ,value: true, description: 'Use std::to_chars for string conversions -- disable for greater compatability with a slight performance cost.') option('default_with_color' ,type: 'boolean' ,value: true, description: 'Enable terminal colors by default -- can also be controlled by command line interface.') option('decompose_successful_assertions' ,type: 'boolean' ,value: true, description: 'Enable expression decomposition even for successful assertions -- more expensive.') option('with_all_reporters' ,type: 'boolean' ,value: true, description: 'Allow all built-in reporters to be selected from the command line -- disable for faster compilation.') diff --git a/tests/runtime_tests/string_utility.cpp b/tests/runtime_tests/string_utility.cpp index 2bb26f6..81b9063 100644 --- a/tests/runtime_tests/string_utility.cpp +++ b/tests/runtime_tests/string_utility.cpp @@ -344,7 +344,7 @@ TEST_CASE("append ints", "[utility]") { TEST_CASE("append floats", "[utility]") { using ae = append_test::append_expected; #if !SNITCH_CONSTEXPR_FLOAT_USE_BITCAST && SNITCH_APPEND_TO_CHARS - // answers will be different only if no bitcast AND we do have runtime to_char + // answers will be different only if no bitcast AND we do have runtime to_chars // otherwise append_constexpr will be used at runtime using aed = append_test::append_expected_diff; #endif @@ -356,14 +356,14 @@ TEST_CASE("append floats", "[utility]") { CONSTEXPR_CHECK(a(0.0f) == ae{"0.000000e+00"sv, true}); #if SNITCH_CONSTEXPR_FLOAT_USE_BITCAST - // std::bit_cast is enabled, and will match the output of std::to_char if used at runtime + // std::bit_cast is enabled, and will match the output of std::to_chars if used at runtime CONSTEXPR_CHECK(a(-0.0f) == ae{"-0.000000e+00"sv, true}); #elif SNITCH_APPEND_TO_CHARS // Without std::bit_cast (or C++23), we are unable to tell the difference between -0.0f and // +0.0f in constexpr expressions. Therefore -0.0f in constexpr gets displayed as +0.0f. CONSTEXPR_CHECK(a(-0.0f) == aed{{"0.000000e+00"sv, true}, {"-0.000000e+00"sv, true}}); #else - // No std::bit_cast, but also no std::to_char. append_constexpr will be used + // No std::bit_cast, but also no std::to_chars. append_constexpr will be used // for runtime and match the compile time results CONSTEXPR_CHECK(a(-0.0f) == ae{"0.000000e+00"sv, true}); #endif @@ -472,7 +472,7 @@ TEST_CASE("append doubles", "[utility]") { CONSTEXPR_CHECK(a(0.0) == ae{"0.000000000000000e+00"sv, true}); #if SNITCH_CONSTEXPR_FLOAT_USE_BITCAST - // std::bit_cast is enabled, and will match the output of std::to_char if used at runtime + // std::bit_cast is enabled, and will match the output of std::to_chars if used at runtime CONSTEXPR_CHECK(a(-0.0) == ae{"-0.000000000000000e+00"sv, true}); #elif SNITCH_APPEND_TO_CHARS // Without std::bit_cast (or C++23), we are unable to tell the difference between -0.0f and @@ -480,7 +480,7 @@ TEST_CASE("append doubles", "[utility]") { CONSTEXPR_CHECK( a(-0.0) == aed{{"0.000000000000000e+00"sv, true}, {"-0.000000000000000e+00"sv, true}}); #else - // No std::bit_cast, but also no std::to_char. append_constexpr will be used for + // No std::bit_cast, but also no std::to_chars. append_constexpr will be used for // runtime and match the compile time results CONSTEXPR_CHECK(a(-0.0) == ae{"0.000000000000000e+00"sv, true}); #endif