SigFigs[] := (* Created by Neil J. Gunther, Tue Jun 18 09:18:54 2002 *) (* Updated by Neil J. Gunther, Tue Jun 18 16:29:01 2002 *) Module[ {numString, digString, intList, realList}, numString = InputString[": "]; (* force string literal *) If[StringMatchQ[numString, "*.*"], (*** must be REAL - valued ***) digString = StringReplace[numString, "." -> ""]; (* elide decimal point *) realList = ToExpression[Characters[digString]]; (* Walk list from LEFTmost digit *) While[Length[realList] != 0, If[First[realList] == 0, realList = Rest[realList], (* delete from head *) Return[{FullForm[numString], Length[realList]}] (* first non-zero digit! *) ]; ], (*** Else: must be an INTEGER ***) intList = ToExpression[Characters[numString]]; (* Walk list from RIGHTmost digit *) While[(len = Length[intList]) != 0, If[Last[intList] == 0, intList = Take[intList, len - 1], (* delete from tail *) Return[{FullForm[numString], Length[intList]}] (* first non-zero digit! *) ]; ]; ] (* end of If *) ] (* end of Module *)