EmbDev.net

Forum: FPGA, VHDL & Verilog Round to nearest


von Da T. (danielts)


Rate this post
useful
not useful
Hi all,

What are the ways of implementation of "round to nearest" function.
It is an analogue of matlab "round" function. For example:

-2.5 is rounded to -3
2.5 is rounded to 3

Thanks in advance,
Daniel

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Three steps:
1. memorize sign (positive or negative value)
2. round the absolute (positive) value (if >=0.5 then round up)
3. apply sign from step 1 to result

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.