int32_t tmp; for (i = 0; i < ARRAYSIZE_PLOT; ++i) { tmp = output[i].r * output[i].r + output[i].i * output[i].i; while (tmp > 0x7FFFFFFF) tmp >>= 1; /* we can only work on positive values */ if (tmp > 0) { tmp = fp_sqrt(tmp, 8); /* linear scaling, nothing bad should happen */ if (logarithmic) { tmp = get_log_value(tmp << 8); /* the log function expects s15.16 values */ } } plot[i] = tmp; }