maths/fast: avoid size_t/float precision warnings

This commit is contained in:
Danny Robson 2019-04-15 10:36:18 +10:00
parent 39107bb62c
commit c718c9bff4

View File

@ -63,8 +63,8 @@ main ()
cruft::TAP::logger tap;
for (unsigned i = 0; i < std::size (sins); ++i) {
const auto theta = cruft::pi<float> / 4 * i / (std::size (sins)-1);
for (std::size_t i = 0; i < std::size (sins); ++i) {
const auto theta = cruft::pi<float> / 4 * static_cast<float> (i) / (std::size (sins) - 1);
const auto value = cruft::maths::fast::sin (theta);
const auto abserr = std::abs (sins[i] - value);
@ -72,9 +72,9 @@ main ()
successes.sin += (abserr < 1e-32f || cruft::relatively_equal (sins[i], value, 1e-6f)) ? 1 : 0;
}
for (unsigned int i = 0; i < std::size (exps); ++i) {
for (std::size_t i = 0; i < std::size (exps); ++i) {
static constexpr float half_log2 = 0.34657359027997265470861606072908828403775006718012f;
const auto exponent = half_log2 * i / (std::size (exps)-1);
const auto exponent = half_log2 * static_cast<float> (i) / (std::size (exps)-1);
const auto value = cruft::maths::fast::exp (exponent);
const auto abserr = std::abs (exps[i] - value);