Files
cgal/Apollonius_graph_2/generators/include/CGAL/bits.h
T
Menelaos Karavelas 3b97659e3f added inclusion of basic.h in random_integer.h
added file for compute log base 2 and bit size
of integers
2006-07-20 18:14:50 +00:00

24 lines
375 B
C

#ifndef CGAL_BITS_H
#define CGAL_BITS_H
#include <CGAL/basic.h>
#include <cmath>
CGAL_BEGIN_NAMESPACE
double log2(double x)
{
return log10(x) / log10(2.0);
}
unsigned int bits(double x)
{
CGAL_precondition( static_cast<int>(x) == x );
if ( x == 0 ) { return 1; }
return static_cast<unsigned int>(log2( fabs(x) )) + 1;
}
CGAL_END_NAMESPACE
#endif // CGAL_BITS_H