Introduce gte float

This commit is contained in:
2024-04-06 21:07:32 -05:00
parent dc42f4a7df
commit 6702e60864
3 changed files with 32 additions and 4 deletions

View File

@@ -50,6 +50,30 @@ static constexpr deg_t operator""_deg(long double degree) {
return deg_t::from_tenth_degree((degree*10.0));
}
struct gte_float : public math::raw_math<gte_float> {
int32_t raw;
static constexpr gte_float from_double(double value) {
return gte_float{.raw = static_cast<int32_t>(4096.0*value)};
}
static constexpr gte_float one() {
return gte_float::from_double(1.0);
}
constexpr explicit operator int32_t() const {
return this->raw;
}
constexpr explicit operator int16_t() const {
return static_cast<int16_t>(this->raw);
}
};
static constexpr gte_float operator""_gf(long double value) {
return gte_float::from_double(value);
}
using sin_t = int32_t;
using cos_t = int32_t;