    inline T mod(const T& x, const T& m) {
      if (!m) throw CImgArgumentException("cimg::mod(): Specified modulo value is 0.");
      const double dx = (double)x, dm = (double)m;
      if (!cimg::type<double>::is_finite(dm)) return x;
      if (cimg::type<double>::is_finite(dx)) return (T)(dx - dm * std::floor(dx / dm));
      return (T)0;
    }
    inline T mod(const T& x, const T& m) {
      if (!m) throw CImgArgumentException("cimg::mod(): Specified modulo value is 0.");
      const double dx = (double)x, dm = (double)m;
      if (!cimg::type<double>::is_finite(dm)) return x;
      if (cimg::type<double>::is_finite(dx)) return (T)(dx - dm * std::floor(dx / dm));
      return (T)0;
    }