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/TMS320F28377S: __divf32 and double?

Part Number: TMS320F28377S

Tool/software: TI C/C++ Compiler

Hello,

In the SPUR514L (Compiler C/C++) there is a chapter about the compiler intrinsics function.

My question is about the "__dif32"

Documentation say:

double __divf32(double num, double denum)

So the input and output are "double" => float 64bits.

the name of the function is _divf32


Is the operator is done on converted input to 32bit or fully done on 64bit?

What is the difference with the instruction "/"?

Thank

  • A GIR said:
    So the input and output are "double" => float 64bits.

    That is incorrect.  Type double is 32-bits.  Type long double is 64-bits.

    Thanks and regards,

    -George

  • Ok

    you are right, this is written in SPUR chapter §6.4.

    This is specific to C2000 compiler. This is why i done the mistake!

    In IEEE standard, float are 32bits, and double are 64bits.

    So how can we interpret the standard C/C++ function like following?:


    long int lroundf (float x);

    long int lround  (double x);

    long int lroundl (long double x);

    with a standard IEEE compiler, we should understand:

    long int lroundf (float x);  => input x is a 32bits

    long int lround  (double x);  => input x is a 64bits

    long int lroundl (long double x); => input x is a 80 or 96 or more bits

    But if I understand, with the provided library for C2000 compiler, should we understand:

    long int lroundf (float x);  => input x is a 32bits

    long int lround  (double x);  => input x is a 32bits

    long int lroundl (long double x); => input x is a 64 bits

    In global, when a standard IEEE function define a "double", we must consider the function is 32 bits float, or C2000 compiler replace the standard function "double" by "long double" to keep 64bits precision?

    Thank

     

  • A GIR said:
    In IEEE standard, float are 32bits, and double are 64bits.

    I'm not sure the IEEE standard says that.  It does define floating point types of different widths.  But how they should be used in any particular compiler is not defined.  All that said, you are correct to say many C compilers implement the types float and double that way.  The way C2000 does it is unusual, but I don't think it violates any standard.

    A GIR said:

    But if I understand, with the provided library for C2000 compiler, should we understand:

    long int lroundf (float x);  => input x is a 32bits

    long int lround  (double x);  => input x is a 32bits

    long int lroundl (long double x); => input x is a 64 bits

    That's correct.

    A GIR said:
    In global, when a standard IEEE function define a "double", we must consider the function is 32 bits float, or C2000 compiler replace the standard function "double" by "long double" to keep 64bits precision?

    In all cases, whether a standard RTS function or a user defined function, the type double always means 32-bits.  To get 64-bits, the type long double must explicitly be used.  In no case does double ever mean more than 32-bits.

    Thanks and regards,

    -George

  • George Mock said:
    The way C2000 does it is unusual, but I don't think it violates any standard.

    That isn't correct.  While the ANSI standard for C never directly says double must be 64-bits wide, it does list some minimum requirements for type double that 32-bit IEEE format does not meet.  In the end, ANSI does require double be 64-bits.  The C2000 compiler violates this aspect of the ANSI C standard.

    Thanks and regards,

    -George