Fixed-Point c++ library for download

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

What are you blinking about Boro?

Post

Sorry for the late answer, I was very busy with my master graduation these days! :wink:
mistertoast wrote:How well does it deal with conversions to and from floating point?
Are you talking about precision or performance?

You can convert from a variety of types, including floating point, using something like this:

Code: Select all

TFix32<16> a(117);             //From int
TFix32<28> b(0.0625f);         //From float
TFix32<20> c(-0.75);           //From double
TFix32<26> d(1+2.f*0.707f);    //Expression
You have to use a TFix32<n> variable with a suitable n of course, to avoid overflow.
If you create those TFix32 objects on the stack, the conversion will be made at compile time, allowing you to write float constants in your code, although it's to be run on non-fp architectures.
You can also write something like this:

Code: Select all

TFix32<29> f29 = 3.141593;
Precision: All of the decimal bits you specified (29) are used
Performance: The conversion is made at compile time

If you are addressing floating point capable architectures, and you want to convert a float to a fixed, let's say:

Code: Select all

TFix32<30> f30 = GetFloatInput();
Precision: All of the decimal bits you specified (30) are used
Performance: The conversion cost is a single float multiplication

Converting fixed point values back to float, double or integer values, costs exactly a float, double division, or an arithmetic shift for the latter:

Code: Select all

// Conversion #1 - calling conversion method
float f = f30.ToFloat();

// Conversion #2 - using automatic casting
float f = f30;
Hope I satisfied your curiosity, anyway I'm always opened to further discussion! :wink:
Free VST Plugins at http://ag-works.net/

Post

You answered my question perfectly. A+.

Post Reply

Return to “DSP and Plugin Development”