aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/numerics.cpp6
-rw-r--r--src/numerics.hpp1
2 files changed, 6 insertions, 1 deletions
diff --git a/src/numerics.cpp b/src/numerics.cpp
index ddf7187..833ac5f 100644
--- a/src/numerics.cpp
+++ b/src/numerics.cpp
@@ -19,13 +19,17 @@
#include <sstream>
Fraction::Fraction(word_t numerator, word_t denominator)
- : numerator{numerator}, denominator{denominator}
+ : numerator{numerator}, denominator{denominator},
+ norm{numerator / ((long double)denominator)}
{
word_t hcf = gcd(MIN(numerator, denominator), MAX(numerator, denominator));
numerator /= hcf;
denominator /= hcf;
}
+// floating point arithmetic inaccuracies blah blah blah better to use
+// simplified fractions here
+
bool Fraction::operator<(const Fraction other)
{
if (other.denominator == denominator)
diff --git a/src/numerics.hpp b/src/numerics.hpp
index c1317cd..43b6c0b 100644
--- a/src/numerics.hpp
+++ b/src/numerics.hpp
@@ -30,6 +30,7 @@ typedef uint64_t word_t;
struct Fraction
{
word_t numerator, denominator;
+ long double norm;
Fraction(word_t numerator = 0, word_t denominator = 1);
bool operator<(const Fraction other);