diff --git a/webapp/server.py b/webapp/server.py index 2ae6a6e..fc4f40d 100644 --- a/webapp/server.py +++ b/webapp/server.py @@ -64,19 +64,11 @@ def parse_fraction(frac_str): def calculate_cents(fraction_str): """Calculate cents from fraction string.""" + import math + fr = parse_fraction(fraction_str) if fr <= 0: return 0 - return 1200 * ( - float(fr).bit_length() - - 1 - + (fr / (1 << (fr.bit_length() - 1)) - 1) / 0.6931471805599453 - if hasattr(fr, "bit_length") - else 1200 * (float(fr).bit_length() - 1) - ) - # Simpler: use log2 - import math - return 1200 * math.log2(fr)