From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 10-MAR-1992 12:31:55.75
To:	ARISIA::EVERHART
CC:	
Subj:	Re: Digit Dissector procedure....

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.123)
	 id AA18580; Tue, 10 Mar 92 11:57:31 EST
Received: From DANPOST.UNI-C.DK by CRVAX.SRI.COM with TCP; Tue, 10 MAR 92 08:51:23 PST
Received: from vms2.uni-c.dk by danpost.uni-c.dk (5.65/1.34)
	id AA12669; Tue, 10 Mar 92 16:50:39 GMT
Date: Tue, 10 Mar 92 17:51 +0100
From: ISIS08@ecostat.aau.dk
Subject: Re: Digit Dissector procedure....
To: STUBRBEE%EKU.bitnet@CUNYVM.CUNY.EDU, INFO-VAX@SRI.COM
Message-Id: <89DC56349A5F016CA1@vms2.uni-c.dk>
X-Envelope-To: STUBRBEE%EKU.bitnet@CUNYVM.CUNY.EDU, INFO-VAX@SRI.COM
X-Vms-To: UNIL63::IN%"STUBRBEE%EKU.bitnet@CUNYVM.CUNY.EDU"
X-Vms-Cc: IN::"INFO-VAX@SRI.COM"

>      I have been trying to hack out a routine that will seperate the digits of
> a given integer.  What i want this procedure to eventually do is to transfer an
> interger value to a string (packed array of char or a varying of char).

> Ps.  Yes i know about UDEC but i may need to port this procedure to our UN*X.
>      So vanilla pascal please!  Thanx!

> Program Duh(Input,Output);
> 
> Var
>   N, L : Integer;
> 
> Procedure Digit_Dissector(N, L : Integer);
> 
>   Var
>     E, M, X: Integer;
> 
>   Begin
>     For X := 1 to L Do
>       Begin
>         E := L + 1 - X;
>         M := Round(N / 10 ** E) * 10 ** E;
>         M := N - M;
>         Writeln(Round(M / (10 ** (E - 1))));
>       End;
>   End;
> 
> Begin
>   Write('Integer:  ');
>   Readln(N);
>   Write('Enter Length:  ');
>   Readln(L);
>   Digit_Dissector(N,L);
> End.

The following modified version of the code works and is reasonable fast.
(Note: the code returns the digits from rigth to left!!!!)

Program Duh(Input,Output);

Procedure Digit_Dissector(N,L : Integer);

Var
  M,I,V : Integer;

Begin
   M := N;
   For I := 1 to L Do Begin
      V := M Mod 10;
      writeln(V);
      M := M Div 10;
   End;
End;

Var
  N,L : Integer;

Begin
  Write('Integer:  ');
  Readln(N);
  Write('Enter Length:  ');
  Readln(L);
  Digit_Dissector(N,L);
End.

                                                          Arne Vajhxj

Arne Vajhxj                             Internet: ISIS08@ECOSTAT.AAU.DK
Institute of Economics and Statistics   PSI:      DATAPAX.23830211371400::ISIS08
Aarhus University
Denmark


