#include <ieeefp.h>
#include "mex.h"

void mexFunction( int nlhs, mxArray *plhs[],
             int nrhs, const mxArray *prhs[] ) {
  switch ((int) mxGetScalar(prhs[0])) {
    case  2 :  fpsetround (FP_RZ); break;
    case  1 :  fpsetround (FP_RP); break;
    case  0 :  fpsetround (FP_RN); break;
    case -1 :  fpsetround (FP_RM); break;
    default :  fpsetround (FP_RN); break;
  }

} /* setround */