mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-15 05:47:38 +00:00
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:
@@ -69,8 +69,12 @@ static inline float angle_approx_4deg0(const complex32_t t) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
static inline float angle_approx_0deg27(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());
|
if( t.real() ) {
|
||||||
return x / (1.0f + 0.28086f * x * x);
|
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) {
|
static inline float angle_precise(const complex32_t t) {
|
||||||
|
Reference in New Issue
Block a user