kar8942
asked on
VB Significant Digits function
Does anyone have a visual basic function that will return a passed number with a requested number of significant digits?
For example:
X = 1.233412
Y = FixSigFigs(X,3) 'I want Y to have 3 significant digits.
Function FixSigFigs( NumberToFix as double, SigFigs as Integer)
For example:
X = 1.233412
Y = FixSigFigs(X,3) 'I want Y to have 3 significant digits.
Function FixSigFigs( NumberToFix as double, SigFigs as Integer)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You didn't specify as to whether you wanted rounding or not. Use the Round() function, as AlexFM suggested, if you need rounding to occur. Otherwise, use my function if you simply want to truncate the number to the requested number of digits.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What did you decide to use?
kar8942 got two ways: rounding and truncating. He should decide what he need. Without his response I think points should be splitted.
ASKER
Neither answer actually worked, but I will split the points anyway. Thanks.