C++ convert to radix 64

10/02/2014 00:01 Andariel666#1
Hi epvpers!

I have a question about converting numbers (decimal) to radix 64.
Tell the truth the conversion is OK, but I have problem with converting it back.

Code:
static long unsigned int base64dec(const char *text)
{
	return strtoull(text, NULL, 64);
}
The code above works perfectly until base 36, because 'strtoull' support only up to 36.


But I would like to convert it back to decimal.

What is the better way to do that?


Thank you.
10/02/2014 09:06 ƬheGame#2
Quote:
Originally Posted by Andariel666 View Post
Hi epvpers!

I have a question about converting numbers (decimal) to radix 64.
Tell the truth the conversion is OK, but I have problem with converting it back.

Code:
static long unsigned int base64dec(const char *text)
{
	return strtoull(text, NULL, 64);
}
The code above works perfectly until base 36, because 'strtoull' support only up to 36.


But I would like to convert it back to decimal.

What is the better way to do that?


Thank you.
Here you go:
[Only registered and activated users can see links. Click Here To Register...]
10/02/2014 10:47 Andariel666#3
Thx, but it isn't right for me.

This source encode everything to base64.
But I would like to convert only DECIMAL NUMBERS to radix 64. This is a simply number system conversion. The encoding works fine, but the decoding doesn't works well....

Here are two examples:

Good for me: [Only registered and activated users can see links. Click Here To Register...]

Bad for me: [Only registered and activated users can see links. Click Here To Register...]

I think base64 encoding isn't the same as convert a number to radix 64.
10/02/2014 11:06 ƬheGame#4
You can do it like that: [Only registered and activated users can see links. Click Here To Register...]

the base64 string cant be longer than 5 bc. a integer wouldnt have enought "place" to store a higher value

if you want to save the result in a string you just have to modify this example a little bit. Then you can convert base64 strings longer than 5
10/02/2014 12:05 Andariel666#5
I would be great, but im not familiar with C#.
Yes, the is an other problem, because I would like to convert very big numbers to short them with the conversion.

May be I could use GMP or MPIR handling the bug numbers.
10/02/2014 15:49 ƬheGame#6
Quote:
Originally Posted by Andariel666 View Post
I would be great, but im not familiar with C#.
Yes, the is an other problem, because I would like to convert very big numbers to short them with the conversion.

May be I could use GMP or MPIR handling the bug numbers.
Its 90% the same code in c++, c, python, java etc.
You just need to adjust it.
10/02/2014 16:42 Andariel666#7
That's true, to convert it C++ not so difficult, but there is a bigger problem.
That code can handle only 32 bit integers. This is too small for my purpose.
I would like to convert for example 200 digited number. That the problem....
10/02/2014 17:07 ƬheGame#8
Quote:
Originally Posted by Andariel666 View Post
That's true, to convert it C++ not so difficult, but there is a bigger problem.
That code can handle only 32 bit integers. This is too small for my purpose.
I would like to convert for example 200 digited number. That the problem....
This will be impossible without an additional library.
10/02/2014 20:54 Andariel666#9
GNP solved the problem. :)