From f8ffb9c0b31c9be77ad4d60d27d6095f3bd83965 Mon Sep 17 00:00:00 2001 From: Amy Retzerau Date: Thu, 13 Nov 2025 13:45:30 +0100 Subject: [PATCH] feat: added isSmall test for vec, and more compere function in decimals --- fastmath.hpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fastmath.hpp b/fastmath.hpp index 751e042..bdf7ebf 100644 --- a/fastmath.hpp +++ b/fastmath.hpp @@ -55,6 +55,12 @@ struct decimal { friend bool operator>(const decimal &d1, const decimal &d2) { return d1.i > d2.i; } + friend bool operator<=(const decimal &d1, const decimal &d2) { + return d1.i <= d2.i; + } + friend bool operator>=(const decimal &d1, const decimal &d2) { + return d1.i >= d2.i; + } friend bool operator==(const decimal &d1, const decimal &d2) { return d1.i == d2.i; @@ -62,7 +68,6 @@ struct decimal { friend bool operator!=(const decimal &d1, const decimal &d2) { return d1.i != d2.i; } - decimal &operator=(decimal const &in) { if (this != &in) { std::destroy_at(this); @@ -155,6 +160,13 @@ template struct vec { } return res; } + bool isSmall() { + for (int i = 0; i < n; i++) { + if (abs(v[i].i) > (1 << (HALF_SHIFT - 1))) + return false; + } + return true; + } decimal &operator[](const int &i) { return v[i]; } decimal len_sq() { return *this * *this; }