#include "unaryoperators.hpp"
#include <cmath>

//Not in the header, as it is not exported to the TMathFunction class.
int fact(int n)
{
 if (n < 0)
  return 0;
 else if (n == 0)
  return 1;
 else
  return n*fact(n-1);
}

double fact(double x)
{
 return (double) (fact((int) x));
}

//King p526
double round(double x)
{
 return (int) ((x < 0.0) ? ceil(x-0.5) : floor(x+0.5));
}
