0

I m currently using the NTL to handle large integers. The large integers on this library are declared as ZZ. I would like to go from a ZZ number to a hexadecimal. However, NTL does not support conversion from ZZ to hexadecimals as I checked.

So my question is how can i go from ZZ (or maybe string which represent large decimal numbers) to hexadecimal forms? I prefer if it is possible to use the fascilities of this library to go directly to hex from ZZ if someone can help

Hashed
  • 57
  • 1
  • 2
  • 6
  • 1
    A number is a number, decimal and hexadecimal are different ways of representing that number. Do you want to convert ZZ to a string that represents its hexadecimal form and vice versa? `"Hex to ZZ"` doesn't really make sense. – Marlon Sep 26 '12 at 13:48
  • yes, I would like to get the hexadecimal form of a ZZ number – Hashed Sep 26 '12 at 13:52

1 Answers1

0

Step1: The large number xx is taken initially as a string s

Step2: Say string s has length l then s=s[0]s[1]...s[l-1]. We read each character of s starting from position 0 and each time we convert this digit to an integer variable digit using int digit = atoi(ts.c_str()); Then we use the recursive relation value=10*value+digit where value is declared as ZZ and initialized to 0. After iterating through all digits we pass string to the ZZ value

Step3: Now to convert to hexadecimal form, using NTL we can compute modulo16 of ZZ numbers. So starting by value%2 and then computing (value-value%16)/16 and proceeding in this way we get the hex form.

Hashed
  • 57
  • 1
  • 2
  • 6