Welcome to mirror list, hosted at ThFree Co, Russian Federation.

llroundl.c « math « mingwex « mingw « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9d2217411d7fe6472609954b45a935acf8646705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <math.h>
#include <limits.h>
#include <errno.h>

long long
llroundl (long double x)
{
  /* Add +/- 0.5, then round towards zero.  */
  long double tmp = truncl (x + (x >= 0.0L ?  0.5L : -0.5L));
  if (!isfinite (tmp) 
      || tmp > (long double)LONG_LONG_MAX
      || tmp < (long double)LONG_LONG_MIN)
    { 
      errno = ERANGE;
      /* Undefined behaviour, so we could return anything.  */
      /* return tmp > 0.0L ? LONG_LONG_MAX : LONG_LONG_MIN; */
    }
  return (long long)tmp;
}