nuttx/libs/libc/math/lib_roundf.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

39 lines
960 B
C

/****************************************************************************
* lib/math/lib_roundf.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
****************************************************************************/
float roundf(float x)
{
float f = modff(x, &x);
if (x <= 0.0f && f <= -0.5f)
{
x -= 1.0f;
}
if (x >= 0.0f && f >= 0.5f)
{
x += 1.0f;
}
return x;
}