aboutsummaryrefslogtreecommitdiffstats
path: root/test/gourdinl/c/floor.c
blob: 33a57af38278cd902cd37f8ed385b169899916d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
int main(int n)
{
  int x = 1, i;

  /* for positive values */
  if (n > 0)
  {
    for (; x <= n >> 1;)
    {
      x = x << 1;
    }
    n = x;
  }
  /* for negative values */
  else
  {
    n = ~n;
    n = n + 1;
    for (; x <= n >> 1;)
    {
      x = x << 1;
    }
    x = x << 1;
    x = ~x;
    x = x + 1;
    n = x;
  }
  return n;
}