diff options
author | Derek Kozel <derek.kozel@ettus.com> | 2016-09-26 17:02:47 -0700 |
---|---|---|
committer | Derek Kozel <derek.kozel@ettus.com> | 2016-09-26 17:07:21 -0700 |
commit | 9af57b2e2c369298cda3153678307b4dee467f53 (patch) | |
tree | 61b237ab631994a04709915b03bacd946701201d | |
parent | c117bd55c1760f43afb90feb43f59e6493daef84 (diff) | |
download | uhd-9af57b2e2c369298cda3153678307b4dee467f53.tar.gz uhd-9af57b2e2c369298cda3153678307b4dee467f53.tar.bz2 uhd-9af57b2e2c369298cda3153678307b4dee467f53.zip |
Fixed floating point rounding error in converter tests
Integer rounding was producing out of range values and causing tests to
fail
-rw-r--r-- | host/tests/convert_test.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/host/tests/convert_test.cpp b/host/tests/convert_test.cpp index 8d359d2e2..84e7480a6 100644 --- a/host/tests/convert_test.cpp +++ b/host/tests/convert_test.cpp @@ -76,8 +76,8 @@ static void test_convert_types_sc16( //fill the input samples std::vector<sc16_t> input(nsamps), output(nsamps); BOOST_FOREACH(sc16_t &in, input) in = sc16_t( - short(((std::rand()/double(RAND_MAX/2)) - 1)*32767/extra_div), - short(((std::rand()/double(RAND_MAX/2)) - 1)*32767/extra_div) + short((float((std::rand())/(double(RAND_MAX)/2)) - 1)*32767/extra_div), + short((float((std::rand())/(double(RAND_MAX)/2)) - 1)*32767/extra_div) ); //run the loopback and test @@ -127,8 +127,8 @@ static void test_convert_types_for_floats( //fill the input samples std::vector<data_type> input(nsamps), output(nsamps); BOOST_FOREACH(data_type &in, input) in = data_type( - ((std::rand()/value_type(RAND_MAX/2)) - 1)*float(extra_scale), - ((std::rand()/value_type(RAND_MAX/2)) - 1)*float(extra_scale) + ((std::rand()/(value_type(RAND_MAX)/2)) - 1)*float(extra_scale), + ((std::rand()/(value_type(RAND_MAX)/2)) - 1)*float(extra_scale) ); //run the loopback and test |