How can I preform significant figure?
Printable View
How can I preform significant figure?
Try this.
private Function SignificantFig(INitialValue as Double, SigFig as Long) as Long
Dim lngtmp as Double, lngtmp2 as Double
lngtmp = 0
lngtmp = CDbl(Log(INitialValue) / Log(10))
lngtmp = Int(lngtmp)
lngtmp2 = INitialValue * 10 ^ (-lngtmp)
' USe "int" with a multiplication here rather than "Round" if you wish to truncate
lngtmp2 = Round(lngtmp2, SigFig - 1)
''''
lngtmp2 = lngtmp2 * 10 ^ lngtmp
SignificantFig = lngtmp2
End Function
Cheers,
surrendermonkey