This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TMS320F28023: Want long double versions of sin(), cos(), and pow()

Part Number: TMS320F28023

Tool/software: TI C/C++ Compiler

Win7 32bit (SP1), CCS 6.2.0.00050, F28023.

I have been attempting to make a coefficient generator using double precision floating point (64bit) math.

I finally figured out you need to define each variable as a long double as simply using double is the same as float (32bit)

I also see I must post-pend the letter L to any constants to make the compiler treat them as a long double (example, 10.0L)

However, the functions like sin(double_variable), cos(double_variable) and pow(10.0L, double_variable) still seem to be doing this in 32bit float size.

It seems that for the following, the C compiler converts the numbers to floats, does the sin, then converts it back to long double.

long double    d_sine_omega;
long double    d_omega;
... some assignment of d_omega...
d_sine_omega = sin(d_omega);

resulting assembly code

3f092c:   5CAD        MOVZ         AR4, @SP
3f092d:   DC92        SUBB         XAR4, #18
3f092e:   5CA4        MOVZ         AR4, @AR4
3f092f:   767F2FB4    LCR          FD$$TOFS
3f0931:   767F2C07    LCR          sin
3f0933:   5CAD        MOVZ         AR4, @SP
3f0934:   DC98        SUBB         XAR4, #24
3f0935:   88A4        MOVZ         AR6, @AR4
3f0936:   767F306D    LCR          FS$$TOFD

Are there long double functions to these?

Thanks, Mark.

  • Cool Javelin said:
    Are there long double functions to these?

    Looking in the include/math.h file from ti-cgt-c2000_19.6.0.STS shows the following log double version of the functions (suffixed with an "l"):

    _CODE_ACCESS long double cosl(long double x);
    _CODE_ACCESS long double sinl(long double x);
    _CODE_ACCESS long double powl(long double x, long double y);

  • Chester, thanks for this I now know there is a solution.

    I am using library 6.4.6, and the include does not have a sinl.

    I note the lib (and compiler or course) for 15.12.3.LTS DOES have the sinl. I may have to step up to that.

    The issue is the newer library is 60% larger then the one I am using and may not fit.

    Maybe I will have to get into creating my own library with bits and pieces from both. My guess is I won't be able to trim off too much as sinl (and cosl and powl) probably call other *l routines that I will need to preserve.

    Thanks,

    Mark.