summaryrefslogtreecommitdiff
path: root/mod.hpp
blob: f0da7c41d8d1477aac09ed68a056d3716633be84 (plain)
1
2
3
4
5
6
7
8
9
10
#pragma once
#include <cmath>

double mod(double a, double b) {
  if (a >= 0) {
    return fmod(a, b);
  } else {
    return fmod(a + b * ceil(-a / b), b);
  }
}