This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Converting code to fixed point


Converting code to fixed point

Postby Pam » Nov 14, 2003 @ 5:42pm

All the easy problems have been solved.
User avatar
Pam
pm Insider
 
Posts: 449
Joined: Jan 24, 2002 @ 10:30pm
Location: Ohio


Postby Pam » Nov 15, 2003 @ 1:58pm

All the easy problems have been solved.
User avatar
Pam
pm Insider
 
Posts: 449
Joined: Jan 24, 2002 @ 10:30pm
Location: Ohio


Postby Dan East » Nov 15, 2003 @ 6:42pm

I haven't had time to go through and find the problem. However I have a suggestion.

If you multiply an int against a fixed point value then the result is a fixed point value (32.0 * 24.8 = 24.8 ). You are converting "power" to fixed point to multiply it against a fixed point value, so you have to shift back after the fixed point mult. Just multiply power as a regular int against what you want to scale, and you don't have to right shift afterward, and you will have an extra 8 bits of range to work with.

The primary problem you will run into with fixed point math is overflow. I'll let you know if I see anything else.

Dan East
Last edited by Dan East on Nov 15, 2003 @ 7:12pm, edited 1 time in total.
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby Dan East » Nov 15, 2003 @ 6:48pm

cos and sin are floating point routines that accept radians. You are converting radians to fixed point and passing that to sin and cos, so those will return off the wall results. You need to create your own fixed point LUT for sin / cos. Instead of passing radians pass something like 0 to 2047, where 2048 is equivalent to 2*pi.

Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby Pam » Nov 15, 2003 @ 7:22pm

Thanks Dan. You are, of course, right as usual.

Pam
All the easy problems have been solved.
User avatar
Pam
pm Insider
 
Posts: 449
Joined: Jan 24, 2002 @ 10:30pm
Location: Ohio


Postby Dan East » Nov 15, 2003 @ 8:53pm

User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum