Fix NaNs coming out of angle_approx_0deg27().

Used in FM demodulator, was causing downstream problems when using the floating point values directly.
This commit is contained in:
Jared Boone 2016-01-11 11:17:33 -08:00
parent 5a532f34a7
commit 64966d4539

View File

@ -69,8 +69,12 @@ static inline float angle_approx_4deg0(const complex32_t t) {
}
*/
static inline float angle_approx_0deg27(const complex32_t t) {
const auto x = static_cast<float>(t.imag()) / static_cast<float>(t.real());
return x / (1.0f + 0.28086f * x * x);
if( t.real() ) {
const auto x = static_cast<float>(t.imag()) / static_cast<float>(t.real());
return x / (1.0f + 0.28086f * x * x);
} else {
return (t.imag() < 0) ? -1.5707963268f : 1.5707963268f;
}
}
static inline float angle_precise(const complex32_t t) {