Files
core_math/tjp/core/math/Accuracy.h
Timothy Prepscius 0807c0286a flatten 20260225
2026-02-25 12:36:47 -05:00

51 lines
719 B
C++

//
// MathIO.h
// common
//
// Created by Timothy Prepscius on 8/4/18.
// Copyright © 2018 Timothy Prepscius. All rights reserved.
//
#pragma once
#include "Real.h"
namespace tjp {
namespace core {
namespace math {
template<typename V>
struct Accuracy
{
V *v;
Real m;
} ;
template<typename V>
Accuracy<V> with_accuracy(V &v, Real m)
{
return Accuracy<V> { &v, m };
}
constexpr s64 compile_time_pow10(const int digits)
{
if (digits == 0)
return 1;
return 10 * compile_time_pow10(digits-1);
}
constexpr Real accuracy_with_digits(const int digits)
{
if (digits < 0)
return 1.0 / compile_time_pow10(-digits);
return compile_time_pow10(digits);
}
} // namespace
} // namespace
} // namespace