PSCF v1.1
Bit.cpp
1/*
2* Util Package - C++ Utilities for Scientific Computation
3*
4* Copyright 2010 - 2017, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "Bit.h"
9#include <util/global.h>
10#include <climits>
11
12namespace Util
13{
14
15 /*
16 * Default constructor.
17 */
19 : mask_(0)
20 {}
21
22 /*
23 * Constructor.
24 */
25 Bit::Bit(unsigned int shift)
26 { setMask(shift); }
27
28 /*
29 * Set the bit mask.
30 */
31 void Bit::setMask(unsigned int shift)
32 {
33 if (shift > sizeof(unsigned int)*CHAR_BIT) {
34 UTIL_THROW("Shift is too large");
35 }
36 mask_ = 1 << shift;
37 }
38
39}
void setMask(unsigned int shift)
Set or reset the bit mask.
Definition: Bit.cpp:31
Bit()
Default constructor.
Definition: Bit.cpp:18
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Definition: global.h:51
Utility classes for scientific computation.
Definition: accumulators.mod:1