sqlines-w/str.cpp
// Compare string representation of numbers (.5 and 0.50 etc)
Compare string representation of numbers (.5 and 0.50 etc)
Compare string representation of numbers ( . 5 and 0 . 50 etc )
bool Str::CompareNumberAsString(const char *first, int flen, const char *second, int slen)
{
	if(first == NULL || second == NULL || flen > 127 || slen > 127)
		return false;
	char part1[128];
	char part2[128];
	int len1 = 0;
	int len2 = 0;
	const char *cur1 = GetIntegerPart(first, flen, part1, &len1);
	const char *cur2 = GetIntegerPart(second, slen, part2, &len2);
	if(len1 != len2)
		return false;
	if(len1 != 0 && len2 != 0 && memcmp(part1, part2, len1) != 0)
		return false;
	len1 = 0;
	len2 = 0;
	GetFractionPartLen(cur1, flen - (cur1 - first), &len1);
	GetFractionPartLen(cur2, slen - (cur2 - second), &len2);
	if(len1 != len2)
		return false;
	if(len1 != 0 && len2 != 0 && memcmp(cur1, cur2, len1) != 0)
		return false;
	return true;
}
bool Str :: CompareNumberAsString ( const char * first , int flen , const char * second , int slen ) { if ( first == NULL || second == NULL || flen > 127 || slen > 127 ) return false ; char part1 [ 128 ] ; char part2 [ 128 ] ; int len1 = 0 ; int len2 = 0 ; const char * cur1 = GetIntegerPart ( first , flen , part1 , & len1 ) ; const char * cur2 = GetIntegerPart ( second , slen , part2 , & len2 ) ; if ( len1 != len2 ) return false ; if ( len1 != 0 && len2 != 0 && memcmp ( part1 , part2 , len1 ) != 0 ) return false ; len1 = 0 ; len2 = 0 ; GetFractionPartLen ( cur1 , flen - ( cur1 - first ) , & len1 ) ; GetFractionPartLen ( cur2 , slen - ( cur2 - second ) , & len2 ) ; if ( len1 != len2 ) return false ; if ( len1 != 0 && len2 != 0 && memcmp ( cur1 , cur2 , len1 ) != 0 ) return false ; return true ; }
Compare string representation of numbers (.5 and 0.50 etc)
Compare string representation of numbers ( . 5 and 0 . 50 etc )
// Get integer parts of the first and second number // Integer part not equal // Do not compare zero integers (0.123 or .123) // Get lengths of fractions of the first and second number // Fractions not equal // Do not compare zero fractions (123.0 or 123.)