[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
Visit site
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.
 
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…