Subversion Repositories Kolibri OS

Rev

Rev 4872 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.  * ====================================================
  3.  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  4.  *
  5.  * Developed at SunPro, a Sun Microsystems, Inc. business.
  6.  * Permission to use, copy, modify, and distribute this
  7.  * software is freely granted, provided that this notice
  8.  * is preserved.
  9.  * ====================================================
  10.  */
  11. /*
  12. FUNCTION
  13. <<nearbyint>>, <<nearbyintf>>--round to integer
  14. INDEX
  15.         nearbyint
  16. INDEX
  17.         nearbyintf
  18.  
  19. ANSI_SYNOPSIS
  20.         #include <math.h>
  21.         double nearbyint(double <[x]>);
  22.         float nearbyintf(float <[x]>);
  23.  
  24. DESCRIPTION
  25. The <<nearbyint>> functions round their argument to an integer value in
  26. floating-point format, using the current rounding direction and
  27. (supposedly) without raising the "inexact" floating-point exception.
  28. See the <<rint>> functions for the same function with the "inexact"
  29. floating-point exception being raised when appropriate.
  30.  
  31. BUGS
  32. Newlib does not support the floating-point exception model, so that
  33. the floating-point exception control is not present and thereby what may
  34. be seen will be compiler and hardware dependent in this regard.
  35. The Newlib <<nearbyint>> functions are identical to the <<rint>>
  36. functions with respect to the floating-point exception behavior, and
  37. will cause the "inexact" exception to be raised for most targets.
  38.  
  39. RETURNS
  40. <[x]> rounded to an integral value, using the current rounding direction.
  41.  
  42. PORTABILITY
  43. ANSI C, POSIX
  44.  
  45. SEEALSO
  46. <<rint>>, <<round>>
  47. */
  48.  
  49. #include <math.h>
  50. #include "fdlibm.h"
  51.  
  52. #ifndef _DOUBLE_IS_32BITS
  53.  
  54. #ifdef __STDC__
  55.         double nearbyint(double x)
  56. #else
  57.         double nearbyint(x)
  58.         double x;
  59. #endif
  60. {
  61.   return rint(x);
  62. }
  63.  
  64. #endif /* _DOUBLE_IS_32BITS */
  65.