I want to divide a fixed-point number (Q31/int32 representing a fractional number with 31 fractional bits) by another Q31/int32. I want to calculate z = y/x, knowing that abs(x)>abs(y). Therefore, z<1 so it can be represented as another Q31/int32. So I thought I would need to left-shift Y by 32 bits, and cast it as an int64. Then I should be able to divide by an int32 (casting not necessary, but there for clarity) and cast back to an int32:
int32_t x, y = ?? ;
int32_t z = (int32_t)( ((int64_t)y<<32) / ((int32_t)x) );
But it doesn't work. Can you see any obvious error?