cf99fb40c9
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.
41 lines
1009 B
C
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
|