Click here to Skip to main content
15,393,146 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Base 36 value math problem Pin
stoneyowl25-May-15 9:33
Memberstoneyowl25-May-15 9:33 
QuestionRe: Base 36 value math problem Pin
Matt T Heffron6-May-15 7:49
professionalMatt T Heffron6-May-15 7:49 
GeneralRe: Base 36 value math problem Pin
Daniel Pfeffer6-May-15 21:21
professionalDaniel Pfeffer6-May-15 21:21 
AnswerRe: Base 36 value math problem Pin
Gerry Schmitz5-May-15 9:53
mveGerry Schmitz5-May-15 9:53 
GeneralRe: Base 36 value math problem Pin
stoneyowl25-May-15 9:58
Memberstoneyowl25-May-15 9:58 
GeneralRe: Base 36 value math problem Pin
Gerry Schmitz5-May-15 10:15
mveGerry Schmitz5-May-15 10:15 
AnswerRe: Base 36 value math problem Pin
Patrice T17-Jun-15 19:00
mvePatrice T17-Jun-15 19:00 
AnswerRe: Base 36 value math problem Pin
Frankie-C6-May-15 7:01
MemberFrankie-C6-May-15 7:01 
A base 36 numbering scheme should be the math rappresentation of a normal numer expressed with 36 different ciphers. Smile | :)
It should be quite an easy task to create a function that converts the strings that you have to plain binary numbers (base 2) understandable to the computer. This function is equivalent to an ascii to bin conversion, only the symbols that have top be handled are 36.
The sequence, I suppose, is: 0 1 2 3 4 5 6 7 8 9 A B C D E F G . . . . . Z
The generic rappresentation of a number expressed in base x is:
Vn*X^n + V(n-1)*X^n-1 + V(n-2)*X^n-2 + ... + V(0)
In plain the sum of all ciphers by the power of the base at the position taken as exponent.
This is sample to convert a base 36 number to a base 2 numberEDIT: This sample converts any ascii rappresentation of a number in all bases between 2 and 36. It acts as the standard atoi, atol, etc. It converts all applicable characters up to the end of string or the first non number with respect to the choosed base. If the first string char is not a valid cipher, or the string is empty it returns NULL.
C++
long long GenRadVal(char *str, int base)
{
	if (base<2 || base>36)
		return 0LL;

	long long val = 0;

	for (int i = 0; str[i]; i++)
	{
		int c = toupper(str[i]);
		if ((c < 0) || ((c > '9') && (c < 'A')) || (c > 'Z'))
			break;
		c =  c > '9' ? c - 'A' + 10 : c - '0';
		if (c >= base)
			break;
		val *= base;
		val +=  c;
	}
	return val;
}

This will give you back a 64 bits number equivalent to the string. To go back to the original value you can use itoa() function in C.
Now comparisons are easy.. Laugh | :laugh:

P.S. the reverse for this function is the stdlib function itoa() with base=36.

modified 17-May-15 12:01pm.

SuggestionRe: Base 36 value math problem Pin
Matt T Heffron6-May-15 7:41
professionalMatt T Heffron6-May-15 7:41 
GeneralRe: Base 36 value math problem Pin
Frankie-C7-May-15 2:07
MemberFrankie-C7-May-15 2:07 
AnswerRe: Base 36 value math problem Pin
Patrice T17-Jun-15 18:37
mvePatrice T17-Jun-15 18:37 
GeneralRe: how does C4.5 work? Pin
PIEBALDconsult25-Apr-15 7:46
professionalPIEBALDconsult25-Apr-15 7:46 
AnswerRe: how does C4.5 work? Pin
pt140125-Apr-15 8:39
Memberpt140125-Apr-15 8:39 
AnswerRe: how does C4.5 work? Pin
Richard MacCutchan25-Apr-15 20:54
mveRichard MacCutchan25-Apr-15 20:54 
AnswerRe: how does C4.5 work? Pin
Kornfeld Eliyahu Peter25-Apr-15 21:01
professionalKornfeld Eliyahu Peter25-Apr-15 21:01 
AnswerRe: algorithm Pin
Sascha Lefèvre25-Apr-15 7:37
professionalSascha Lefèvre25-Apr-15 7:37 
Questionalgorithm Pin
Deepak Pundir17-Apr-15 9:10
MemberDeepak Pundir17-Apr-15 9:10 
AnswerRe: algorithm Pin
Sascha Lefèvre17-Apr-15 9:48
professionalSascha Lefèvre17-Apr-15 9:48 
GeneralRe: algorithm Pin
harold aptroot17-Apr-15 9:54
Memberharold aptroot17-Apr-15 9:54 
GeneralRe: algorithm Pin
PIEBALDconsult15-May-15 14:42
professionalPIEBALDconsult15-May-15 14:42 
QuestionAlgorithm for finding the best “route” of tasks Pin
Nino Cotec2-Apr-15 5:50
MemberNino Cotec2-Apr-15 5:50 
AnswerRe: Algorithm for finding the best “route” of tasks Pin
Chris Losinger2-Apr-15 9:41
professionalChris Losinger2-Apr-15 9:41 
AnswerRe: Algorithm for finding the best “route” of tasks Pin
Patrice T25-Jun-15 8:44
mvePatrice T25-Jun-15 8:44 
QuestionCreate continuous path from multiple segments Pin
Member 115731191-Apr-15 3:38
MemberMember 115731191-Apr-15 3:38 
AnswerRe: Create continuous path from multiple segments Pin
Frankie-C2-Apr-15 1:27
MemberFrankie-C2-Apr-15 1:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.