
(*
Digits is an obsolete function.  It has been superseded by
IntegerDigits (for integer arguments) and RealDigits (for real arguments).
*)

Begin["System`"]

Unprotect[Digits]
Digits::usage =
"Digits is an obsolete function, superseded by IntegerDigits and RealDigits.\n
Digits[n] gives a list of the digits of the integer n.
Digits[n, b] gives a list of the digits in base b. Digits[x, b] gives
a list containing a list of digits of the integer part of x, a list
of digits of the fractional part, and the exponent of b."

Begin["`Private`"]

ToInteger[char_String] :=
    With[{t = ToCharacterCode[char][[1]]},
        If[t < 58, t-48, t-87]
    ]

Digits[n_Real,base_:10] := Module[{v,man={},i,exp={"0"}},
    Message[Digits::obsfn, Digits, {IntegerDigits, RealDigits}];
    v = Characters[ToString[InputForm[BaseForm[Abs[n],base]]]];
    If[MemberQ[v,"*"],
        exp = Drop[v,Last[Position[v,"^"]][[1]]];
        v = Take[v,Last[Position[v,"*"]][[1]]-1];
    ];
    If[MemberQ[v,"^"],
        v = Drop[v,Last[Position[v,"^"]][[1]]]];
    If[MemberQ[v,"."],
        i = Last[Position[v,"."]][[1]];
        man = Drop[v,i];
        v = Take[v,i-1];
    ];
    {ToInteger /@ v, 
     ToInteger /@ man, 
     ToExpression[Apply[StringJoin,exp]] }
]

Digits[n_Integer,base_:10] := Module[ {v,man={},i},
    Message[Digits::obsfn, Digits, {IntegerDigits, RealDigits}];
    v = Characters[ToString[InputForm[BaseForm[Abs[n],base]]]];
    If[MemberQ[v,"^"], v = Drop[v,Last[Position[v,"^"]][[1]]]];
    ToInteger /@ v
]

Protect[Digits]
End[]
End[]

Null
