# Passing a BigInt (mpz\_t for GMP) array to C

**URL:** <https://discourse.julialang.org/t/passing-a-bigint-mpz-t-for-gmp-array-to-c/123622>\
**Category:** General Usage\
**Created:** [December 9, 2024, 2:25pm UTC](https://discourse.julialang.org/t/passing-a-bigint-mpz-t-for-gmp-array-to-c/123622 "2024-12-09T14:25:06Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![Questioner](https://avatars.discourse-cdn.com/v4/letter/q/e8c25b/32.png) [@Questioner](https://discourse.julialang.org/u/Questioner)\
**Post date:** [May 6, 2025, 8:36pm UTC](https://discourse.julialang.org/t/passing-a-bigint-mpz-t-for-gmp-array-to-c/123622/21 "2025-05-06T20:36:14Z")

</div>

Here’s a new problem. Consider the following C code:

```julia
#include<gmp.h>

void fibonacci(mpz_t** fibs, unsigned int l) {
	//Set the first two numbers
	if(l > 0) {
		mpz_set_ui(*fibs[0], 0);
	}
	if(l > 1) {
		mpz_set_ui(*fibs[1], 1);
	}
	//Calculate the remaining array
	if(l > 2) {
		mpz_t temp;
		mpz_init(temp);
		for(int k = 2; k < l; k++) {
			mpz_add(temp, *fibs[k-1], *fibs[k-2]);
			mpz_set(*fibs[k], temp);
		}
	}
}

```

Calling this in Julia works perfectly well up to l=94, but at l=95 the numbers become so large that C has to create new limbs. This crashes Julia with a spectacularly long error message.

[Previous page](https://discourse.julialang.org/t/passing-a-bigint-mpz-t-for-gmp-array-to-c/123622.md?page=1)
