Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

lpm_divide remainder result

My thread is mainly on the remainder output from the lpm_divide.

I am using the lpm_divide megafunction for diving two 16 bit fixed point numbers and the denominator is always greater than or equal to the numerator. Meaning, the result of the division in my case would be less than 1 90% of the time. The quotient of the megafunction would give either a 0 or 1. But what about the remainder?

For example, (0.25 / 0.50) * (2^15/2^15) = 8192/16384 using lpm_divide would give a quotient 0. But would the remainder be simply 8192?

Thanks in advance for the help.

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    That's correct you should get that value as the remainder. As a result I would prescale the numerator more than the denominator so that you get a quotient that is beyond 0 or 1 (otherwise you don't really need a divider to figure out the answer....)