/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
float roundf(float x) {
  float y, r;

  y = floor (x);                /* Largest integer <= x */
  r = x - y;                    /* Fractional part */
  /* Round up to nearest */
  if (r > 0.5) {
    y += 1.0;
    return (y);
  }
  /* Round to even */
  if (r == 0.5) {
    r = y - 2.0 * floor (0.5 * y);
    if (r == 1.0) {
      y += 1.0;
    }                           /* Else round down */
  }
  return (y);
}
