Line 12... |
Line 12... |
// Creator: Dan Gisselquist, Ph.D.
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Technology, LLC
|
// Gisselquist Technology, LLC
|
//
|
//
|
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
//
|
//
|
// This program is free software (firmware): you can redistribute it and/or
|
// This program is free software (firmware): you can redistribute it and/or
|
// modify it under the terms of the GNU General Public License as published
|
// modify it under the terms of the GNU General Public License as published
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// your option) any later version.
|
// your option) any later version.
|
Line 48... |
Line 48... |
r |= (-1l << bits);
|
r |= (-1l << bits);
|
return r;
|
return r;
|
}
|
}
|
|
|
bool sfits(const long val, const int bits) {
|
bool sfits(const long val, const int bits) {
|
long alt = sbits(val, bits);
|
|
return (sbits(val, bits) == bits);
|
return (sbits(val, bits) == bits);
|
}
|
}
|
|
|
unsigned long ubits(const long val, const int bits) {
|
unsigned long ubits(const long val, const int bits) {
|
unsigned long r = val & ((1l<<bits)-1);
|
unsigned long r = val & ((1l<<bits)-1);
|