How to use big integer in Pascal

1 Answer

0 votes
program BigIntExample;

uses
  gmp;

var
  a, b, c: mpz_t;

begin
  // Initialize the big integers
  mpz_init(a);
  mpz_init(b);
  mpz_init(c);

  // Set values to the big integers
  mpz_set_str(a, '123456789012345678901234567890', 10);
  mpz_set_str(b, '867546233727000111100111282737', 10);

  // Perform addition
  mpz_add(c, a, b);

  // Print the result
  writeln('Result of addition: ', mpz_get_str(nil, 10, c));

  // Clear the big integers to free memory
  mpz_clear(a);
  mpz_clear(b);
  mpz_clear(c);
end.




(*
run:

Result of addition: 991003022739345790001345850627

*)  

 



answered May 6 by avibootz
...