nuttx/libs/libc/math/lib_roundl.c
Gregory Nutt cf99fb40c9 This commit moves all of the libraries under a common directory called libs/. This most certainly break libcxx and uClibc++ for now.
Squashed commit of the following:

    libs/libxx:  Fix some confusing in naming.  If the directory is called libxx, then the library must be libxx.a (unless perhaps LIBCXX is selected).
    libs/:  Fix paths in moved library directories.
    libs:  Brute force move of libc, libnx, and libxx to libs.  Cannot yet build it in that configuration.
2018-05-29 13:21:26 -06:00

41 lines
1009 B
C

/****************************************************************************
* lib/math/lib_round.c
*
* This file is a part of NuttX:
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* (C) 2012 Petteri Aimonen <jpa@nx.mail.kapsi.fi>
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <math.h>
/****************************************************************************
* Public Functions
****************************************************************************/
#ifdef CONFIG_HAVE_LONG_DOUBLE
long double roundl(long double x)
{
long double f = modfl(x, &x);
if (x <= 0.0 && f <= -0.5)
{
x -= 1.0;
}
if (x >= 0.0 && f >= 0.5)
{
x += 1.0;
}
return x;
}
#endif