Re: 8.24-bit Fixed point Math
Re: 8.24-bit Fixed point Math
- Subject: Re: 8.24-bit Fixed point Math
- From: David Duncan <email@hidden>
- Date: Sat, 08 Nov 2008 08:34:28 -0800
On Nov 8, 2008, at 2:28 AM, Mark's Studio wrote:
I am porting an AU to the iPhone,
and since the canonical format is 8.24 on the device,
i thought it might be better to do the processing in that format.
I presume you mean as a part of your application...
Fixed point math is reasonably simple, you just have to know a few
details to get it right.
Addition and subtraction are the same as always (8.24 + 8.24 => 8.24).
The only thing you have to worry about is standard integer overflow.
Multiplication is a little complicated however, as you get a double
precision result (8.24 * 8.24 => 16.48). Thus you need to worry about
both clipping and you have to shift back by the number of fractional
bits (i.e. right shift by 24 after the multiplication.
Division is the opposite problem, as you divide away all the
fractional bits, so you need to shift back again. Division tends to be
rare in performance code anyway, but a left shift by 24 after a
division gets you more or less what you need.
For most other operations you can just treat it like the underlying
operation. Conversion from Int to Fixed (and back) are just bit
shifts, and conversion to/from Float is multiplication/division by the
shift value (1<<24 in this case).
--
Reality is what, when you stop believing in it, doesn't go away.
Failure is not an option. It is a privilege reserved for those who try.
David Duncan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden