Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 15:40

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C++ convert to radix 64

Discussion on C++ convert to radix 64 within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2013
Posts: 43
Received Thanks: 0
Exclamation C++ convert to radix 64

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.
Andariel666 is offline  
Old 10/02/2014, 09:06   #2
 
elite*gold: 198
Join Date: Mar 2011
Posts: 835
Received Thanks: 263
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:
ƬheGame is offline  
Old 10/02/2014, 10:47   #3
 
elite*gold: 0
Join Date: Feb 2013
Posts: 43
Received Thanks: 0
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:

Bad for me:

I think base64 encoding isn't the same as convert a number to radix 64.
Andariel666 is offline  
Old 10/02/2014, 11:06   #4
 
elite*gold: 198
Join Date: Mar 2011
Posts: 835
Received Thanks: 263
You can do it like that:

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
ƬheGame is offline  
Old 10/02/2014, 12:05   #5
 
elite*gold: 0
Join Date: Feb 2013
Posts: 43
Received Thanks: 0
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.
Andariel666 is offline  
Old 10/02/2014, 15:49   #6
 
elite*gold: 198
Join Date: Mar 2011
Posts: 835
Received Thanks: 263
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.
ƬheGame is offline  
Thanks
1 User
Old 10/02/2014, 16:42   #7
 
elite*gold: 0
Join Date: Feb 2013
Posts: 43
Received Thanks: 0
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....
Andariel666 is offline  
Old 10/02/2014, 17:07   #8
 
elite*gold: 198
Join Date: Mar 2011
Posts: 835
Received Thanks: 263
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.
ƬheGame is offline  
Old 10/02/2014, 20:54   #9
 
elite*gold: 0
Join Date: Feb 2013
Posts: 43
Received Thanks: 0
GNP solved the problem.
Andariel666 is offline  
Reply

Tags
base64, c++, convert, number


Similar Threads Similar Threads
Kick to convert: easy and fast way to convert your item_proto/mob_proto to txt files!
09/07/2016 - Metin2 PServer Guides & Strategies - 21 Replies
Hi all, this is my first release :) This "kick converter" will allow you to generate txt files (item_names, item_proto, mob_proto, mob_names) for the rev-34k game. The script was written in python by me, so you need python 2.7 and MySQLDB (python extension) installed on your server. If you found any error, please report it to me and I'll fix it as soon as possibile. PS: If you get errors while converting the item_proto, please remove items that have type 29 or type 31.
[Zian]Archlord Battle 22/06/2013 Spartanii vs Radix , Spartanii WON - Radix got PWNED
07/12/2013 - Archlord - 77 Replies
Enjoy the videos ! :) Archlord Battle 22/06/2013 Spartanii vs Radix , Spartanii WON - Radix got PWNED !!! - YouTube Perverts Archlord Battle 22 6 13 - YouTube
asm - convert.
01/15/2012 - General Coding - 5 Replies
Hi, can I ask you to rework it so that you can compile the Dev-C++ int getCharW(int Font, char* Name, int nAlign) { int TextLen = strlen(Name); int nret = 0; __asm { push nAlign push TextLen
Radix Sort C#
11/19/2011 - C/C++ - 0 Replies
Hallo Community, ich habe ein kleines Problem. Ich habe schon das meistse des Quelltextes kommentiert, allerdings verstehe ich den in #ten gekennzeichneten Bereich nicht.... Ich wäre euch sehr dankbar, wenn Ihr mir beim verstehen dieser 4 Zeilen behilflich sein könntet! :) /* Written by Sanchit Karve (born2c0de) Contact Me at born2c0de AT dreamincode DOT net



All times are GMT +2. The time now is 15:40.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.