OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libm/] [mathfp/] [s_floor.c] - Diff between revs 148 and 158

Only display areas with differences | Details | Blame | View Log

Rev 148 Rev 158
 
 
/* @(#)z_floor.c 1.0 98/08/13 */
/* @(#)z_floor.c 1.0 98/08/13 */
 
 
/*
/*
FUNCTION
FUNCTION
<<floor>>, <<floorf>>, <<ceil>>, <<ceilf>>---floor and ceiling
<<floor>>, <<floorf>>, <<ceil>>, <<ceilf>>---floor and ceiling
INDEX
INDEX
        floor
        floor
INDEX
INDEX
        floorf
        floorf
INDEX
INDEX
        ceil
        ceil
INDEX
INDEX
        ceilf
        ceilf
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <math.h>
        #include <math.h>
        double floor(double <[x]>);
        double floor(double <[x]>);
        float floorf(float <[x]>);
        float floorf(float <[x]>);
        double ceil(double <[x]>);
        double ceil(double <[x]>);
        float ceilf(float <[x]>);
        float ceilf(float <[x]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <math.h>
        #include <math.h>
        double floor(<[x]>)
        double floor(<[x]>)
        double <[x]>;
        double <[x]>;
        float floorf(<[x]>)
        float floorf(<[x]>)
        float <[x]>;
        float <[x]>;
        double ceil(<[x]>)
        double ceil(<[x]>)
        double <[x]>;
        double <[x]>;
        float ceilf(<[x]>)
        float ceilf(<[x]>)
        float <[x]>;
        float <[x]>;
 
 
DESCRIPTION
DESCRIPTION
<<floor>> and <<floorf>> find
<<floor>> and <<floorf>> find
@tex
@tex
$\lfloor x \rfloor$,
$\lfloor x \rfloor$,
@end tex
@end tex
the nearest integer less than or equal to <[x]>.
the nearest integer less than or equal to <[x]>.
<<ceil>> and <<ceilf>> find
<<ceil>> and <<ceilf>> find
@tex
@tex
$\lceil x\rceil$,
$\lceil x\rceil$,
@end tex
@end tex
the nearest integer greater than or equal to <[x]>.
the nearest integer greater than or equal to <[x]>.
 
 
RETURNS
RETURNS
<<floor>> and <<ceil>> return the integer result as a double.
<<floor>> and <<ceil>> return the integer result as a double.
<<floorf>> and <<ceilf>> return the integer result as a float.
<<floorf>> and <<ceilf>> return the integer result as a float.
 
 
PORTABILITY
PORTABILITY
<<floor>> and <<ceil>> are ANSI.
<<floor>> and <<ceil>> are ANSI.
<<floorf>> and <<ceilf>> are extensions.
<<floorf>> and <<ceilf>> are extensions.
 
 
*/
*/
 
 
/*****************************************************************
/*****************************************************************
 * 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"
 
 
#ifndef _DOUBLE_IS_32BITS
#ifndef _DOUBLE_IS_32BITS
 
 
double
double
_DEFUN (floor, (double),
_DEFUN (floor, (double),
              double x)
              double x)
{
{
  double f, y;
  double 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 = modf (x, &f);
  y = modf (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);
}
}
 
 
#endif /* _DOUBLE_IS_32BITS */
#endif /* _DOUBLE_IS_32BITS */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.