

<B>CountSigFigsB> 
$n=CountSigFigs($N); This returns the number of significant figures in a number. It returns () if $N is not a number.
$N $n   240 2 240. 3 241 3 0240 2 0.03 1 0 0 0.0 0 
<B>FormatSigFigsB> 
$str=FormatSigFigs($N,$n) This returns a string containing $N formatted to $n significant figures. This will work for all cases except something like 2400 formatted to 3 significant figures.
$N $n $str    2400 1 2000 2400 2 2400 2400 3 2400 2400 4 2400. 2400 5 2400.0 141 3 141. 141 2 140 0.039 1 0.04 0.039 2 0.039 9.9 1 10 9.9 2 9.9 9.9 3 9.90 
<B>addSF, subSF, multSF, divSFB>  These routines add/subtract/multiply/divide two numbers while maintaining the proper number of significant figures. 
<B>Without scientific notation, some numbers are ambiguousB> These routines do not work with scientific notation (exponents). As a result, it is impossible to unambiguously format some numbers. For example,
$str = FormatSigFigs("2400",3);will by necessity return the string 2400 which does NOT have 3 significant figures. This is not a bug. It is simply a fundamental problem with working with significant figures when not using scientific notation.
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Sullivan Beck (sbeck@cpan.org)
perl v5.20.3  MATH::SIGFIGS (3)  20150416 
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.