The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Apr 25th, 2024, 6:26pm
Pages: 1
Send Topic Print
Is there HSPICE function that rounds a parameter's value to the nearest integer? (Read 795 times)
AA
Junior Member
**
Offline



Posts: 21

Is there HSPICE function that rounds a parameter's value to the nearest integer?
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.
Back to top
 
 
View Profile   IP Logged
AA
Junior Member
**
Offline



Posts: 21

Re: Is there HSPICE function that rounds a parameter's value to the nearest integer?
Reply #1 - 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.

Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Is there HSPICE function that rounds a parameter's value to the nearest integer?
Reply #2 - Nov 21st, 2016, 12:11pm
 
Some simulator I was using recently has "nint" for nearest integer.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.