arbeiten mit gmp
-
Hi!
Also... ich hab folgendes Problemchen!
ich habe nen String und will den umwandeln in ne große Zahl, die ich dann in nen mpz_t stecke, also ne sehr großen ganzzahligen datentyp... das kann ich machen mit der funktionint mpz_set_str (mpz t rop, char *str, int base) [Function]
{Set the value of rop from str, a null-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 rst two characters are \0x" or \0X",
hexadecimal is assumed, otherwise if the rst character is \0", octal is assumed, otherwise
decimal is assumed.
This function returns 0 if the entire string is a valid number in base base. Otherwise it returns}gibbet dazu denn auch umgekehrt ne Funktion zu? die mir ne mpz in nen string packt? und wenn nicht... wie sähe die aus wenn man sie sich basten müsste?
dank euch schonmal!
mfg
Tommy
-
Hi,
char* cs = new char[mpz_sizeinbase(value_, base) + 2];
mpz_get_str(cs, base, value_);
std::string str_r(cs); delete[] cs;dunarr
-
dank dir!