W
William Hughes
I would not say dealing with 16 bit signed quality, rather treat the
high part of a 32 bit value as a 16 bit signed value. Anyway, the
operation is actually check the highest bit of the 32 bit value, if that
is not one, shift until it is, and increase the counter each time when
the value shifted.
The comparison uses what is stored in a pointer to int16_t.
This is a 16 byte signed int.
So you are shifting a 32 bit quantity, but checking
a 16 bit quantity.
I tested this piece of loop code, and I say, the result proves that I am
right, the MSB value ranges from 1 to 32. What is the byte ordering in
your system? On my testing system as well as the target platform, it is
little endian.
Hum ... I now understand your concern. Actually it is my fault, because
it's almost impossible to show the whole code in Usenet, I modified the
code to declear some global variable as local variable (with same data
type). CorrValue is, in the original program, global value
Yes, for the moment, I don't have a document for the code. So I have to
get know from the code that what is the hell transform. And, I belive,
the result can also help me understand the problem domain itself.
Try to find out what needs to be done, ignore the question
of how (i.e. ignore all code and code documentation, look
for specifications and code design). The needed info may
be lost in the mists of time and never written down
to begin with, but given the crap code you have anything
is worth trying.
- William Hughes