From a052d57243e00f0e0de15ed6b8d02e60cbd755fe Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 5 Aug 2018 12:21:17 +0200 Subject: Rename library "chilbert" --- chilbert/GetBits.hpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 chilbert/GetBits.hpp (limited to 'chilbert/GetBits.hpp') diff --git a/chilbert/GetBits.hpp b/chilbert/GetBits.hpp new file mode 100644 index 0000000..48428fc --- /dev/null +++ b/chilbert/GetBits.hpp @@ -0,0 +1,39 @@ +/* + Copyright (C) 2018 David Robillard + Copyright (C) 2006-2007 Chris Hamilton + + 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) any later + version. + + 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 . +*/ + +#ifndef _GETBITS_HPP_ +#define _GETBITS_HPP_ + +#include "chilbert/Operations.hpp" + +namespace chilbert { + +template +inline void getBits(const H& h, // bits to read + const int n, // number of bits + const int i, // bit index + I& w) // destination +{ + for (int j = 0; j < n; j++) { + setBit(w, j, testBit(h, i + j)); + } +} + +} // namespace chilbert + +#endif -- cgit v1.2.1