I'll try again, since you seem to have ignored my previous post.
Your data is right justified, e.g.
datatex*sf
datatext = 00000101_00000000
sf = 2**-8 = 1/256 (i.e. right shift by 8)
datatext*sf = 00000000_00000101
once you've done your calculations on these right shifted integers (no Q format used here) you end up doing a division
data_diff_sq/a
which turns your integer into an integer and fractional value, where the fractional part is dropped when assigned to data_var.
Q formats have an integer part and a fractional part, you don't scale them you use them as is. You scale to convert from an integer to a Q format or from Q format back to integer.
If the first data is supposed to be a 5 (decimal) then the Q format is something like Q8.8, i.e. 16-bits with 8 integer bits and 8 fractional bits.
You should read the wiki page on
Q format.