Community
cancel
Showing results for
Did you mean:
Highlighted
Valued Contributor III
1,048 Views

## What is the best Floating number method?

Hello friends...

I want to know what is the efficient code to implement this equation :

1/4 ( x+y) + 1/2

However, inputs are integers , and the output will be also rounded to integer. But the intermediate calculations needs to use 1/4 and 1/2.

Kindly inform me about the best way to code this equation.

Thanks...:)
Tags (1)
4 Replies
Highlighted
Valued Contributor III
12 Views

use fixed point. Its just integer with an offset (so easily implemented in an FPGA).

Highlighted
Valued Contributor III
12 Views

PS: (x+y)/4 + 1/2 is identical to the equation (x+y + 2) /4. divides by 2^n are just a bit shift.

Highlighted
Valued Contributor III
12 Views

--- Quote Start ---

use fixed point. Its just integer with an offset (so easily implemented in an FPGA).

--- Quote End ---

yes use fixe point. just add x + y then add half of result and truncate 2 LSBs

I am assuming you want to add x+y, divide by 4 then round
Highlighted
Valued Contributor III
12 Views

Thank you very much. I am coding it right now to see how it is going. Best regards.