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.

Floating Point Number Division 32-bit v. 64-bit

Other Parts Discussed in Thread: TMS320F28069

Hi team,

We are using the TMS320F28069 in our design and had some questions about the division on floating point numbers.

We have two numbers: A = 0x3f7fffff and B = 0x3f52b7db. When we do the operation B/A (B divided by A) on our TMS320F28069 with the C2000 6.4.6 compiler, we get 0x3f52b7dd as the result. When we run the algorithm on our 64 bit machine compiled with gcc 4.8.4, we are getting 0x3f52b7dc as the result.

What could be some reasons for the difference in the result?

Regards,

Akash Patel

  • Akash,

    There could be a few reasons. A couple that I can think of offhand:

    The algorithm the codegen uses for divide. For example if you use the C28x fast RTS library you may get a slightly different answer than if you use the normal RTS library. One uses a newton raphson algo and the other uses an expansion series.

    Intermediate results may be > 32bits on the 64bit machine and thus the rounding is different.

    Regards
    Lori
  • HI Lori,

    Thanks for the response. Do we have a FastRTS library or simulator that can be used on a 64-bit Linux machine?

    If we do not use FastRTS on our MCU, how much slower would a floating point division take? Is there a way to use multiple math libraries in the same source file in order to use a different implementation of a divide at a specific point in our algorithm?

    Regards,
    Akash Patel
  • Hi Akash,

    Akash Patel said:
    Do we have a FastRTS library or simulator that can be used on a 64-bit Linux machine?

    Unfortunately no. We do give out the assembly source code - these routines are fairly small - and you could probably piece together the algorithm from the comments.

    Akash Patel said:
    If we do not use FastRTS on our MCU, how much slower would a floating point division take?

    The fastRTS division takes 24 cycles in 0-wait state memory; i dont have the numbers for the std C division but i recall them being a lot more than 24.

    Akash Patel said:
    Is there a way to use multiple math libraries in the same source file in order to use a different implementation of a divide at a specific point in our algorithm?

    Both division routines go by the name of FS$$DIV so you will have to modify the FastRTS library as follows:

    1. div_f32.asm: change all instances of FS$$DIV to say, FastDiv

    2. C28x_FPU_FastRTS.h: add float32 FastDiv( float32 numerator, float32 denominator);

    3. rebuild the Fast RTS library

    Now in your test code you can compare the std div vs fast RTS div as follows

    a/b uses std C FS$$DIV

    FastDiv(a, b) uses your modifed FastRTS library division

    You should now be able to compare both routines.