[Programación] Re: [Programación] Re: [Programació n] Enteros grandes (ejemplo)

Nicolás Aimetti programacion@lugro.org.ar
Fri, 18 Nov 2005 14:09:23 +0000


 >> A.assign("123456789123456789123456789"); en este caso siendo A el
 >> numero_grande le asigna el valor entero del numero que contiene esa
 >> cadena.. no se si alguien podria echarme una mano..

Un ejemplo:

/* para compilar:  gcc foo.c -lgmp */

#include <stdio.h>
#include <gmp.h>
#include <assert.h>


int main(int argc, char *argv[]){
     mpz_t entero;
     int err;

     mpz_init_set_str(entero,"123456789123456789123456789",10);
     gmp_printf("numero: %Zd",entero);
     mpz_add_ui(entero,entero,10);
     gmp_printf(" + 10 = %Zd\n",entero);

     mpz_clear (entero);
     return 0;
}


Saludos,
         Nicolás.


Nicolás Aimetti wrote:
> Proba está: http://www.swox.com/gmp/
> 
> Es bastante típica, es parte del proyecto GNU y la usan un motnón de 
> aplicaciones... además es muy buena.
> 
> Multiple Precision Arithmetic Library, the fastest bignum library on the 
> planet!
> 
> GMP is a free library for arbitrary precision arithmetic, operating on 
> signed integers, rational numbers, and floating point numbers. There is 
> no practical limit to the precision except the ones implied by the 
> available memory in the machine GMP runs on. GMP has a rich set of 
> functions, and the functions have a regular interface.
> 
> 
> Saludos,
>         Nicolás.
> 
> 
> Emiliano Nuńez wrote:
> 
>> Hola , estoy buscando una libreria que me permita trabajar con numeros 
>> grandes en c , numeros enteros positivos de longitud arbitraria,, la 
>> libreria me tendria que permitir transformar un cadena a entero, por 
>> ejemplo:
>>