File: misc.c

package info (click to toggle)
libzn-poly 0.8-1.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 700 kB
  • sloc: ansic: 9,295; python: 162; makefile: 7; sh: 6
file content (56 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
   misc.c:  various random things that don't belong anywhere else
   
   Copyright (C) 2007, 2008, David Harvey
   
   This file is part of the zn_poly library (version 0.8).
   
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 2 of the License, or
   (at your option) version 3 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#include "zn_poly_internal.h"


char* ZNP_version_string = "0.8";


const char* zn_poly_version_string()
{
   return ZNP_version_string;
}


int floor_lg(ulong x)
{
   int result = -1;
   while (x)
   {
      x >>= 1;
      result++;
   }
   
   return result;
}


int ceil_lg(ulong x)
{
   ZNP_ASSERT(x >= 1);

   return floor_lg(x - 1) + 1;
}


// end of file ****************************************************************