URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 207 |
Rev 345 |
|
|
/* @(#)z_floorf.c 1.0 98/08/13 */
|
/* @(#)z_floorf.c 1.0 98/08/13 */
|
/*****************************************************************
|
/*****************************************************************
|
* floor
|
* floor
|
*
|
*
|
* Input:
|
* Input:
|
* x - floating point value
|
* x - floating point value
|
*
|
*
|
* Output:
|
* Output:
|
* Smallest integer less than x.
|
* Smallest integer less than x.
|
*
|
*
|
* Description:
|
* Description:
|
* This routine returns the smallest integer less than x.
|
* This routine returns the smallest integer less than x.
|
*
|
*
|
*****************************************************************/
|
*****************************************************************/
|
|
|
#include "fdlibm.h"
|
#include "fdlibm.h"
|
#include "zmath.h"
|
#include "zmath.h"
|
|
|
float
|
float
|
_DEFUN (floorf, (float),
|
_DEFUN (floorf, (float),
|
float x)
|
float x)
|
{
|
{
|
float f, y;
|
float f, y;
|
|
|
if (x > -1.0 && x < 1.0)
|
if (x > -1.0 && x < 1.0)
|
return (x >= 0 ? 0 : -1.0);
|
return (x >= 0 ? 0 : -1.0);
|
|
|
y = modff (x, &f);
|
y = modff (x, &f);
|
|
|
if (y == 0.0)
|
if (y == 0.0)
|
return (x);
|
return (x);
|
|
|
return (x >= 0 ? f : f - 1.0);
|
return (x >= 0 ? f : f - 1.0);
|
}
|
}
|
|
|
#ifdef _DOUBLE_IS_32BITS
|
#ifdef _DOUBLE_IS_32BITS
|
double floor (double x)
|
double floor (double x)
|
{
|
{
|
return (double) floorf ((float) x);
|
return (double) floorf ((float) x);
|
}
|
}
|
|
|
#endif /* defined(_DOUBLE_IS_32BITS) */
|
#endif /* defined(_DOUBLE_IS_32BITS) */
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.