diff options
author | Tom Rondeau | 2011-10-24 11:34:55 -0400 |
---|---|---|
committer | Tom Rondeau | 2011-10-24 11:34:55 -0400 |
commit | 645ad4ae1423926f0fb893bbb5d3463b2c17623a (patch) | |
tree | 5d5a9665aaa370281e267d0ae6ecd56f552c79ee /gnuradio-core/src/lib/general | |
parent | c2908fcffe42589a63bcfc63718454965fdec12b (diff) | |
download | gnuradio-645ad4ae1423926f0fb893bbb5d3463b2c17623a.tar.gz gnuradio-645ad4ae1423926f0fb893bbb5d3463b2c17623a.tar.bz2 gnuradio-645ad4ae1423926f0fb893bbb5d3463b2c17623a.zip |
core: really fixed this on 32-bit machines (actually tested). Forced to promote to a 64-bit int to handle the overflow, so this is going to take a hit on 32-bit machines.
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r-- | gnuradio-core/src/lib/general/gri_float_to_int.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gnuradio-core/src/lib/general/gri_float_to_int.cc b/gnuradio-core/src/lib/general/gri_float_to_int.cc index 8a05da7b4..7f170a9d5 100644 --- a/gnuradio-core/src/lib/general/gri_float_to_int.cc +++ b/gnuradio-core/src/lib/general/gri_float_to_int.cc @@ -27,20 +27,21 @@ #define _ISOC9X_SOURCE #include <gri_float_to_int.h> #include <math.h> +#include <stdint.h> -static const long int MAX_INT = 2147483647; // (2^31)-1 -static const long int MIN_INT = -2147483648; // -2^31 +static const int64_t MAX_INT = 2147483647; // (2^31)-1 +static const int64_t MIN_INT = -2147483647; // -(2^31)-1 void gri_float_to_int (const float *in, int *out, int nsamples) { for (int i = 0; i < nsamples; i++){ - long int r = static_cast<long int>(rint(in[i])); + int64_t r = static_cast<int64_t>(rint(in[i])); if (r < MIN_INT) r = MIN_INT; else if (r > MAX_INT) r = MAX_INT; - out[i] = r; + out[i] = static_cast<int>(r); } } |