aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-01-04 07:36:51 -0800
committerMartin Braun <martin.braun@ettus.com>2017-01-04 07:36:51 -0800
commitf86f209b3370be54ec0870186ab1b9d8988736eb (patch)
tree8a64cec1ab7b22af390240815e7ba86b4d9b7cf6 /host/lib
parent8bd2a5fae547fa1c23da2a78f4f5e61552c431d0 (diff)
downloaduhd-f86f209b3370be54ec0870186ab1b9d8988736eb.tar.gz
uhd-f86f209b3370be54ec0870186ab1b9d8988736eb.tar.bz2
uhd-f86f209b3370be54ec0870186ab1b9d8988736eb.zip
utils: Fixed minor rounding issue in gain_group
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/utils/gain_group.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/host/lib/utils/gain_group.cpp b/host/lib/utils/gain_group.cpp
index 9428702d1..71caf33be 100644
--- a/host/lib/utils/gain_group.cpp
+++ b/host/lib/utils/gain_group.cpp
@@ -39,7 +39,7 @@ static bool compare_by_step_size(
*
* Due to small doubleing-point inaccuracies:
* num = n*step + e, where e is a small inaccuracy.
- * When e is negative, floor would yeild (n-1)*step,
+ * When e is negative, floor would yield (n-1)*step,
* despite that n*step is really the desired result.
* This function is designed to mitigate that issue.
*
@@ -49,7 +49,11 @@ static bool compare_by_step_size(
* \return a multiple of step approximating num
*/
template <typename T> static T floor_step(T num, T step, T e = T(0.001)){
- return step*int(num/step + e);
+ if (num < T(0)) {
+ return step*int(num/step - e);
+ } else {
+ return step*int(num/step + e);
+ }
}
gain_group::~gain_group(void){