Skip to content

Instantly share code, notes, and snippets.

@rasgo-cc
Last active August 29, 2015 14:23
Show Gist options
  • Save rasgo-cc/1cbf9cc771d5fc54b155 to your computer and use it in GitHub Desktop.
Save rasgo-cc/1cbf9cc771d5fc54b155 to your computer and use it in GitHub Desktop.
op1 = (int32_t)(f_op1*(double)scaler); // op1 in Qn format
op2 = (int32_t)(f_op2*(double)scaler); // op2 in Qn format
// Convert the dividend to Q(2*n) format
tmp = ((uint64_t)op1 << Qn);
// Round by summing half the divisor
tmp += op2 >> 1;
// Division
tmp /= (uint64_t)(op2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment