Showing results for

- Intel Community
- FPGAs and Programmable Solutions
- Intel® Quartus® Prime Software
- What is the best Floating number method?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

Altera_Forum

Valued Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-18-2016
11:35 AM

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...:)
4 Replies

Highlighted
##

Altera_Forum

Valued Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-18-2016
11:42 AM

12 Views

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

Highlighted
##

Altera_Forum

Valued Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-18-2016
11:44 AM

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
##

--- 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

Altera_Forum

Valued Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-18-2016
11:45 AM

12 Views

Highlighted
##

Altera_Forum

Valued Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-19-2016
05:53 AM

12 Views

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

For more complete information about compiler optimizations, see our Optimization Notice.