Nov 14, 2014 #1 S shaiko Advanced Member level 5 Joined Aug 20, 2011 Messages 2,644 Helped 303 Reputation 608 Reaction score 297 Trophy points 1,363 Activity points 18,302 Hello, Is there a standard VHDL function that accepts real numbers and rounds them down? For example: signal x : real x <= 14.6 ; A function that when applied on X will return 14.0
Hello, Is there a standard VHDL function that accepts real numbers and rounds them down? For example: signal x : real x <= 14.6 ; A function that when applied on X will return 14.0
Nov 14, 2014 #2 ads-ee Super Moderator Staff member Joined Sep 10, 2013 Messages 7,944 Helped 1,822 Reputation 3,654 Reaction score 1,808 Trophy points 1,393 Location USA Activity points 60,207 function FLOOR (X : real ) return real; There is also a corresponding CEIL function
Nov 14, 2014 #3 T TrickyDicky Advanced Member level 7 Joined Jun 7, 2010 Messages 7,110 Helped 2,081 Reputation 4,181 Reaction score 2,048 Trophy points 1,393 Activity points 39,769 and the trunc function too. x <= trunc(14.6);
Nov 15, 2014 #4 S shaiko Advanced Member level 5 Joined Aug 20, 2011 Messages 2,644 Helped 303 Reputation 608 Reaction score 297 Trophy points 1,363 Activity points 18,302 What's the functional deference between "floor" and "trunc"?
Nov 15, 2014 #5 ads-ee Super Moderator Staff member Joined Sep 10, 2013 Messages 7,944 Helped 1,822 Reputation 3,654 Reaction score 1,808 Trophy points 1,393 Location USA Activity points 60,207 without looking at the actual package body the fucntion descriptions seems to indicate semantically different but identical behavior.
without looking at the actual package body the fucntion descriptions seems to indicate semantically different but identical behavior.
Nov 15, 2014 #6 mrflibble Advanced Member level 5 Joined Apr 19, 2010 Messages 2,720 Helped 679 Reputation 1,360 Reaction score 652 Trophy points 1,393 Activity points 19,551 Presumably floor() and trunc() will give different results for negative numbers. floor(-42.42) = -43 trunc(-42.42) = -42
Presumably floor() and trunc() will give different results for negative numbers. floor(-42.42) = -43 trunc(-42.42) = -42
Nov 15, 2014 #7 S shaiko Advanced Member level 5 Joined Aug 20, 2011 Messages 2,644 Helped 303 Reputation 608 Reaction score 297 Trophy points 1,363 Activity points 18,302 Different result for negatives and same result for positives?
Nov 15, 2014 #8 mrflibble Advanced Member level 5 Joined Apr 19, 2010 Messages 2,720 Helped 679 Reputation 1,360 Reaction score 652 Trophy points 1,393 Activity points 19,551 Yes. From the man pages: floor(x) ... return the largest integral value that is not greater than x. trunc(x) ... round x to the nearest integer not larger in absolute value.
Yes. From the man pages: floor(x) ... return the largest integral value that is not greater than x. trunc(x) ... round x to the nearest integer not larger in absolute value.