FaceGen 3 SDKs Reference
Loading...
Searching...
No Matches
algs.cpp
1//
2// Copyright (c) Singular Inversions Inc. 1999.
3//
4// Authors: Andrew Beatty
5// Created: Nov 5, 1999.
6//
7
8#include "stdafx.h"
9
10#include "algs.hpp"
11#include "FgSerial.hpp"
12
13using namespace std;
14
15namespace Fg {
16
17uint
18fr2Log2Floor(uint a)
19{
20 FGASSERT(a > 0); // Minus infinity we don't do here...
21 uint b=0;
22 do
23 {
24 a = a >> 1; // Shift right one bit, high bit 0 filled for
25 b++; // non-negative numbers.
26 } while (a > 0);
27
28 return (b-1);
29}
30
31uint
32fr2Log2Ceil(uint a)
33{
34 if (a == fr2Pow2Floor(a))
35 return fr2Log2Floor(a);
36 else
37 return (fr2Log2Floor(a) + 1);
38}
39
40}