p++ in Fixed Point??
Started by ●April 27, 2005
Hello all,
Thank You for help and useful tips.
Is there any special way for implementing variable increment in fixed
point such as p++;
for eg.
plc[i]+=(*p0)*a;
p++;
or this can be left as such?
because p++ is euqivalent to p=p+1.Shouldnt this cause a prob if 'p' is
in a different representation format(say Q2.13).
Thanks
Aditya
Reply by ●April 27, 20052005-04-27
Assume p is x.y format. Then p++ is
p = p+ ((1<<y)-1)
if p saturates(max value of x.y reached), change Q-format of p to x+1.y-1
by scaling down.
Enjoy
A
aditya_naidu1 <a...@pmail.ntu.edu.sg> wrote:
Hello all,
Thank You for help and useful tips.
Is there any special way for implementing variable increment in fixed
point such as p++;
for eg.
plc[i]+=(*p0)*a;
p++;
or this can be left as such?
because p++ is euqivalent to p=p+1.Shouldnt this cause a prob if 'p' is
in a different representation format(say Q2.13).
Thanks
Aditya
NEW! You can now post a message or access and search the archives of this group on DSPRelated.com:
http://www.dsprelated.com/groups/speechcoding/1.php
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group.
_____________________________________
About this discussion group:
Archives: http://www.dsprelated.com/groups/speechcoding/1.php
To Post: Send an email to s...@yahoogroups.com
Other DSP Related Groups: http://www.dsprelated.com/groups.php
__________________________________________________
Reply by ●April 27, 20052005-04-27
What would you increment by? I would suggest p += x with x being
your increment value.
At 12:25 AM 4/27/2005, aditya_naidu1 wrote:
>Hello all,
>
>Thank You for help and useful tips.
>Is there any special way for implementing variable increment in fixed
>point such as p++;
>
>for eg.
>
>plc[i]+=(*p0)*a;
>p++;
>
>or this can be left as such?
>because p++ is euqivalent to p=p+1.Shouldnt this cause a prob if 'p' is
>in a different representation format(say Q2.13).
>
>Thanks
>Aditya
Steve Holle
Link Communications, Inc.
1035 Cerise Rd.
Billings, MT 59101
sholle@shol...
Reply by ●April 27, 20052005-04-27
> Date: Wed, 27 Apr 2005 06:25:45 -0000
> From: "aditya_naidu1" <adityanaidu@adit...>
>
> Is there any special way for implementing variable increment in fixed
> point such as p++;
>
> for eg.
>
> plc[i]+=(*p0)*a;
> p++;
>
> or this can be left as such?
> because p++ is euqivalent to p=p+1.Shouldnt this cause a prob if 'p' is
> in a different representation format(say Q2.13).
As you said, p++ is equivalent to p = p + 1, where p and 1 are integers.
This means that if the variable represents a fixed point Q3.12 value,
p++ increments the LSB, which is equial to 2**(-13). If a 1.0 was to be
added to a Q2.13 value, the Q2.13's 1.0 has to be written as 0x2000
or 8192 decimal.
Regards,
Andrew