Skip to content

Commit

Permalink
iox-eclipse-iceoryx#2055 Set new digits for aarch64
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Liu <[email protected]>
  • Loading branch information
Dennis40816 committed Jan 14, 2024
1 parent cba5170 commit ef269b7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion iceoryx_hoofs/test/moduletests/test_utility_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,28 @@ class convert_test : public Test
static_assert(std::is_floating_point<T>::value, "fp_to_string requires floating point type");

std::ostringstream oss;
oss << std::scientific << std::setprecision(std::numeric_limits<T>::max_digits10) << value;
oss << std::scientific << std::setprecision(get_digits<T>()) << value;
return oss.str();
}

private:
// see https://github.com/eclipse-iceoryx/iceoryx/pull/2155
template <typename T>
constexpr static uint32_t get_digits()
{
if constexpr (std::is_same_v<T, float>)
{
return 9;
}
else if (std::is_same_v<T, double> || std::is_same_v<T, long double>)
{
return 19;
}
else
{
static_assert("T should be floating point");
}
}
};


Expand Down

0 comments on commit ef269b7

Please sign in to comment.