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.

[SOLVED] system verilog squareroot with out rounding....

Status
Not open for further replies.

dipin

Full Member level 4
Joined
Jul 16, 2014
Messages
223
Helped
14
Reputation
28
Reaction score
14
Trophy points
18
Activity points
1,731
hi,

in system verilog , to find the square root $sqrt(x) function can be used . but it is rounding the values.

example if the input value is 95 then $sqrt(x) will give root as 10.
is there any way to get it as 9??????

i have tried t**0.5 also. but it too rounding the value.:???:

i am new in system verilog. if you know please help.


thanks & regards
 

$sqrt() doesn't perform any rounding, it takes place because you assign the result to integer variable.

To get the intended result, learn about $floor() and $ceil(). You should also get a basic understanding of numeric types and automatic type conversions in SV to solve similar problems yourself.
 
  • Like
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating
hi,

thanks fvm . i used $floor()

regards
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top