Jump to content
43oh

Faster division of a float?


Recommended Posts

The FR5739 has the MPY32 hardware multiplier. I would like to use this to speed up the division of a floating point number, float/int. From what I assume, in place of X/Y, I can use X*(1/Y) and use the hardware multiplier. From http://www.ti.com/lit/an/slaa329/slaa329.pdf it would seem that I lose the remainder when doing the division. Is there a faster way to do floating point division with integers but retain accuracy?

 

Currently, I am using the DMA to speed up ADC conversions but then losing cycles during the division. I know I can use the DMA to directly enter the data into the MPY32 registers but then I'll still lose accuracy.

Link to post
Share on other sites

x / y

 

multiply x by 10000 and truncate it - so you get an integer out of the float with 4 decimals, then do a normal integer - integer - division ... and in the last step divide it by 10000 to get the result - i dont know if it is faster - but you can give it a try ;)

 

something like this (untested)

float x = 1.234567;
int y = 7;
int z = x * 10000;
float result = z / (y * 10000);

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...