The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Simulators >> Circuit Simulators >> Is there HSPICE function that rounds a parameter's value to the nearest integer?
https://designers-guide.org/forum/YaBB.pl?num=1479489483

Message started by AA on Nov 18th, 2016, 9:18am

Title: Is there HSPICE function that rounds a parameter's value to the nearest integer?
Post by AA on Nov 18th, 2016, 9:18am

Hi,

I know there is an HSPICE function int(x) that returns the integer part of parameter x.

But, is there a similar function that rounds a parameter value to the nearest integer? For example, if the param value is 1.9, the function should return 2.

Thank you.

Title: Re: Is there HSPICE function that rounds a parameter's value to the nearest integer?
Post by AA on Nov 18th, 2016, 9:49am

I've just realized that this can be done using the same int() function.

To round x to the nearest integer (assuming x is positive), we use int(x+0.5).

I hope someone will find this useful in the future.


Title: Re: Is there HSPICE function that rounds a parameter's value to the nearest integer?
Post by Geoffrey_Coram on Nov 21st, 2016, 12:11pm

Some simulator I was using recently has "nint" for nearest integer.

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.