Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Standart VHDL function that rounds down numbers

Status
Not open for further replies.

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
 

function FLOOR (X : real ) return real;

There is also a corresponding CEIL function
 
and the trunc function too.

x <= trunc(14.6);
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
What's the functional deference between "floor" and "trunc"?
 

without looking at the actual package body the fucntion descriptions seems to indicate semantically different but identical behavior.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Presumably floor() and trunc() will give different results for negative numbers.

floor(-42.42) = -43

trunc(-42.42) = -42
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Different result for negatives and same result for positives?
 

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.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top