Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Create your online store today with Shopify

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Disclosure: My content contains affiliate links.

43,227 questions

56,129 answers

573 users

How to convert an array of digits to a number in Pascal

2 Answers

0 votes
program DigitsToNumberMath;

function DigitsToNumberMath(arr: array of Integer): Int64;
var
  n, i: Int64;
begin
  n := 0;
  for i := 0 to High(arr) do
    n := n * 10 + arr[i];   { shift left and add digit }

  DigitsToNumberMath := n;
end;

var
   digits: array[0..6] of Integer = (9, 4, 6, 3, 9, 1, 2);
  n: Int64;

begin
  n := DigitsToNumberMath(digits);
  WriteLn('Using math method: ', n);
end.



(*
run:
 
Using math method: 9463912
 
*)

 



answered Oct 4, 2025 by avibootz
edited May 11 by avibootz
0 votes
program DigitsToNumber;

uses SysUtils;

function DigitsToNumberStr(arr: array of Integer): Int64;
var
  s: string;
  i: Integer;
begin
  s := '';
  
  for i := 0 to High(arr) do
    s := s + IntToStr(arr[i]);   { append digit as text }

  DigitsToNumberStr := StrToInt(s);         { convert final string to integer }
end;

var
  digits: array[0..6] of Integer = (9, 4, 6, 3, 9, 1, 2);
  n: Int64;

begin
  n := DigitsToNumberStr(digits);
  
  WriteLn('Using string method: ', n);
end.



(*
run:
 
Using string method: 9463912
 
*)

 



answered May 11 by avibootz
...