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.

TMS320C28x div IEEE 754 rounding method setting

Other Parts Discussed in Thread: TMS320F2810

I am using  C2000 (v6.4.9) compiler for TMS320C28x without FPU.

 What I can notice is that float operations (division) seems to round “towards zero” e.g. truncate the result.

My question is if there is a way to configure the rounding behavior to “round to nearest, ties to even”, either in C2000 v6.4.9 or in any of the more resent compiler versions, and in such case from which version?

Thanks

  • Fredrik,

    Our compiler expert is out until Tuesday.  Looking at the C2000 compiler users guide I found this section:

    I do not see any options to change that behavior.

    Regards,

    John

  • This is basically the information I found as well.
    To me it neither confirms or denies that division round's towards zero. Or whether it's possible to change that behavior.

    Regards

    /Fredrik

  • The compiler does not support any mode but "round to nearest, ties to even," so it doesn't provide any options to change the rounding mode.  It is possible to change the rounding mode in assembly code, but the compiler requires you to change the rounding mode back to "round to nearest, ties to even" before re-entering any C code, and this has to be done in assembly code.

    Floating-point division is supposed to round in this manner; do you have a test case that demonstrates truncating (round to zero) behavior?

  • float A = 1.002002954483032F; // as U32 -> 0x3F8041A2
    float B = 0.999000012874603F; // as U32 -> 0x3F7FBE77
    float C = A/B;

    The result C is with
    C2000 v6.4.9
    HEX:0x3F80627F BIN:0 01111111 00000000110001001111111 DEC:1.003005862236023

    MinGW v8.1.0 (for comparison)
    HEX:0x3F806280 BIN:0 01111111 00000000110001010000000 DEC:1.003005981445313 

    In double for reference (64bit ) the result is
    HEX: 0x3FF00C4FF6E47B23 BIN:0 01111111111 0000000011000100111111110110111001000111101100100011 DEC:1.0030059475172457000000000

  • Additional info; The test was performed using TMS320F2810.

    /Fredrik

  • Thank you for the concise test case.  I can reproduce the same result.  I filed EXT_EP-10879 to have this investigated.  You are welcome to follow it with that link.

    Thanks and regards,

    -George