From 1bbea9cd3060ef65a2623f156b4f12ebf62c52fe Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 27 Jan 2022 01:38:39 -0800 Subject: Start and use a standard-like numbers header --- common/alnumbers.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 common/alnumbers.h (limited to 'common/alnumbers.h') diff --git a/common/alnumbers.h b/common/alnumbers.h new file mode 100644 index 00000000..98994b44 --- /dev/null +++ b/common/alnumbers.h @@ -0,0 +1,32 @@ +#ifndef COMMON_ALNUMBERS_H +#define COMMON_ALNUMBERS_H + +#include + +namespace al { + +namespace numbers { + +namespace detail_ { + template + using as_fp = std::enable_if_t::value, T>; +} // detail_ + +template +static constexpr auto pi_v = detail_::as_fp(3.141592653589793238462643383279502884L); + +template +static constexpr auto inv_pi_v = detail_::as_fp(0.318309886183790671537767526745028724L); + +template +static constexpr auto sqrt3_v = detail_::as_fp(1.732050807568877293527446341505872367L); + +static constexpr auto pi = pi_v; +static constexpr auto inv_pi = inv_pi_v; +static constexpr auto sqrt3 = sqrt3_v; + +} // namespace numbers + +} // namespace al + +#endif /* COMMON_ALNUMBERS_H */ -- cgit v1.2.3