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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [mathfp/] [s_floor.c] - Blame information for rev 258

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
 
2
/* @(#)z_floor.c 1.0 98/08/13 */
3
 
4
/*
5
FUNCTION
6
<<floor>>, <<floorf>>, <<ceil>>, <<ceilf>>---floor and ceiling
7
INDEX
8
        floor
9
INDEX
10
        floorf
11
INDEX
12
        ceil
13
INDEX
14
        ceilf
15
 
16
ANSI_SYNOPSIS
17
        #include <math.h>
18
        double floor(double <[x]>);
19
        float floorf(float <[x]>);
20
        double ceil(double <[x]>);
21
        float ceilf(float <[x]>);
22
 
23
TRAD_SYNOPSIS
24
        #include <math.h>
25
        double floor(<[x]>)
26
        double <[x]>;
27
        float floorf(<[x]>)
28
        float <[x]>;
29
        double ceil(<[x]>)
30
        double <[x]>;
31
        float ceilf(<[x]>)
32
        float <[x]>;
33
 
34
DESCRIPTION
35
<<floor>> and <<floorf>> find
36
@tex
37
$\lfloor x \rfloor$,
38
@end tex
39
the nearest integer less than or equal to <[x]>.
40
<<ceil>> and <<ceilf>> find
41
@tex
42
$\lceil x\rceil$,
43
@end tex
44
the nearest integer greater than or equal to <[x]>.
45
 
46
RETURNS
47
<<floor>> and <<ceil>> return the integer result as a double.
48
<<floorf>> and <<ceilf>> return the integer result as a float.
49
 
50
PORTABILITY
51
<<floor>> and <<ceil>> are ANSI.
52
<<floorf>> and <<ceilf>> are extensions.
53
 
54
*/
55
 
56
/*****************************************************************
57
 * floor
58
 *
59
 * Input:
60
 *   x  - floating point value
61
 *
62
 * Output:
63
 *   Smallest integer less than x.
64
 *
65
 * Description:
66
 *   This routine returns the smallest integer less than x.
67
 *
68
 *****************************************************************/
69
 
70
#include "fdlibm.h"
71
#include "zmath.h"
72
 
73
#ifndef _DOUBLE_IS_32BITS
74
 
75
double
76
_DEFUN (floor, (double),
77
              double x)
78
{
79
  double f, y;
80
 
81
  if (x > -1.0 && x < 1.0)
82
    return (x >= 0 ? 0 : -1.0);
83
 
84
  y = modf (x, &f);
85
 
86
  if (y == 0.0)
87
    return (x);
88
 
89
  return (x >= 0 ? f : f - 1.0);
90
}
91
 
92
#endif /* _DOUBLE_IS_32BITS */

powered by: WebSVN 2.1.0

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