Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • $\begingroup$ "I do not end up with 60" -- what do you end up with? if you end up with $60 \pm \epsilon$, and $\epsilon$ is significantly smaller than the errors caused by noise in your input data, then you're close enough. If you end up with 2 or 200, then you have problems. $\endgroup$ Commented Dec 17, 2022 at 15:42
  • $\begingroup$ It would be helpful if you would edit your question with this information. $\endgroup$ Commented Dec 17, 2022 at 16:56
  • $\begingroup$ @TimWescott I updated with all the steps and the final result which is far from 60. Either my Downscale or Upscale functions are wrong or it's not possible in general to take it back to the original range and expect matching results? $\endgroup$ Commented Dec 17, 2022 at 18:51
  • 2
    $\begingroup$ "Q31" (which I would call "Q1.31") is not the only way to do 32-bit fixed point. If you have a range up to ±64.0 (or -64.0 to +63.999999999), then the fixed-point format that you want is Q7.25. 25 bits to the right of the binary point. This means that, in a language like C, your integer representation is $2^{25}$ times larger than the value it represents. $\endgroup$ Commented Dec 17, 2022 at 19:22
  • $\begingroup$ Multiply in Q31: 2576980*4294967 >> 31 = 5152 ...... Why are you shifting right 31 bits? And you know that right-shifting loses precision, right? There is truncation. Are you rounding in that truncation? Also, have you considered that your intermediate value from multiplication might be too big for a 32-bit word? You might need to do that in int64_t. $\endgroup$ Commented Dec 17, 2022 at 22:57