elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  mpz_set_str()
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: mpz_set_str()  (Leído 1,523 veces)
m@o_614


Desconectado Desconectado

Mensajes: 389


Ver Perfil
mpz_set_str()
« en: 18 Marzo 2014, 15:41 pm »

alguien que conozca alguna funcion de la libreria gmp que me permita ingresar enteros??, tengo la función mpz_set_str(num,text.c_str(),10); pero en esta el segundo miembro tiene que ser un string, y eso es lo que no quiero necesito una función que me ingrese un entero sin el uso de cadenas

gracias


En línea

eferion


Desconectado Desconectado

Mensajes: 1.248


Ver Perfil
Re: mpz_set_str()
« Respuesta #1 en: 18 Marzo 2014, 15:50 pm »

¿Es esto lo que buscabas?

Código:
Assignment Functions


These functions assign new values to already initialized integers (see section Initialization and Assignment Functions).

Function: void mpz_set (mpz_t rop, mpz_t op)
Function: void mpz_set_ui (mpz_t rop, unsigned long int op)
Function: void mpz_set_si (mpz_t rop, signed long int op)
Function: void mpz_set_d (mpz_t rop, double op)
Function: void mpz_set_q (mpz_t rop, mpq_t op)
Function: void mpz_set_f (mpz_t rop, mpf_t op)
    Set the value of rop from op.

Function: int mpz_set_str (mpz_t rop, char *str, int base)
    Set the value of rop from str, a '\0'-terminated C string in base base. White space is allowed in the string, and is simply ignored. The base may vary from 2 to 36. If base is 0, the actual base is determined from the leading characters: if the first two characters are `0x' or `0X', hexadecimal is assumed, otherwise if the first character is `0', octal is assumed, otherwise decimal is assumed.
    This function returns 0 if the entire string up to the '\0' is a valid number in base base. Otherwise it returns -1.



En línea

Gh057


Desconectado Desconectado

Mensajes: 1.190



Ver Perfil
Re: mpz_set_str()
« Respuesta #2 en: 18 Marzo 2014, 16:00 pm »

hola m@o_614, las mayoría de las funciones definidas en esa biblioteca aceptan tanto números, como cadenas; es por un tema de eficiencia. (puedes pasar el entero a cadena y operar de una manera más rápida)

-> http://es.wikipedia.org/wiki/GNU_Multiple_Precision_Arithmetic_Library

-> https://gmplib.org/manual/

adentro tienes un detalle extenso de toda la bibioteca, sin embargo te dejo un enlace directo a el manejo con enteros.

-> https://gmplib.org/manual/Integer-Functions.html#Integer-Functions

(igual mira el tema del manejo de candenas...)

espero haberte ayudado, saludos.
En línea

4 d0nd3 1r4 3l gh057? l4 r3d 3s 74n v4s74 3 1nf1n1t4...
m@o_614


Desconectado Desconectado

Mensajes: 389


Ver Perfil
Re: mpz_set_str()
« Respuesta #3 en: 19 Marzo 2014, 01:03 am »

Muchas gracias ahora ya comprendi mejor para que sirve cada función
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines