TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: STEVEN READ
from: EDWARD RUTLEDGE
date: 1997-06-24 01:32:00
subject: Part 4 of 3 - OOPS

 
int Days_Between ( long start, long end ) 
	{ 
	int temp1 = 0; 
	int temp2 = 0; 
	int startx; 
	int endx; 
 
	if ( ( end / 1000 ) > ( start / 1000 ) ) 
		{ 
		startx = start / 1000; 
		endx = end / 1000; 
 
		} 
	else 
		{ 
		endx = start / 1000; 
		startx = end / 1000; 
		} 
	for ( int running = startx + 1; running <= endx; running ++ ) 
		temp2 += Days_in_year ( running ); 
	temp1 = ( ( end % 1000 ) - ( start % 1000 ) ); 
	if ( ( end / 1000 ) > ( start / 1000 ) ) 
		return temp1 + temp2; 
	else 
		return temp1 - temp2; 
	} 
 
int Days_in_year ( long oops ) 
	{ 
	if ( oops > 10000 ) 
		oops /= 1000; 
	if ( ( oops % 4 ) == 0 ) 
		{ 
		if ( oops % 100 == 0 && oops % 400 != 0 ) 
			return 365; 
		else 
			return 366; 
		} 
	else 
		return 365; 
	} 
 
char character ( char* doit ) 
	{ 
	return *doit; 
	} 
 
/* 
Routine to convert "character" numbers into long double decimal values. 
(In this case used if values are brought through the command line input.) 
*/ 
 
long double char_t_float ( char* ps ) 
	{ 
	long double build ( long double, int, int& );	// Prototype function 
	long double temp = 0.0; 
	int flag = 0; 
	int nflag = 0; 
	int pflag = 0; 
	while ( *ps ) 
		{ 
		switch ( *ps ++ ) 
			{ 
			case '0':	// Convert 0 
				temp = build ( temp, 0, flag ); 
				break; 
			case '1':	// Convert 1 
				temp = build ( temp, 1, flag ); 
				break; 
			case '2':	// Convert 2 
				temp = build ( temp, 2, flag ); 
				break; 
			case '3':	// Convert 3 
				temp = build ( temp, 3, flag ); 
				break; 
			case '4':	// Convert 4 
				temp = build ( temp, 4, flag ); 
				break; 
			case '5':	// Convert 5 
				temp = build ( temp, 5, flag ); 
				break; 
			case '6':	// Convert 6 
				temp = build ( temp, 6, flag ); 
				break; 
 
			case '7':	// Convert 7 
				temp = build ( temp, 7, flag ); 
				break; 
			case '8':	// Convert 8 
				temp = build ( temp, 8, flag ); 
				break; 
			case '9':	// Convert 9 
				temp = build ( temp, 9, flag ); 
				break; 
			case ',':	// Ignores commas 
				break; 
			case '.':	// Processes a period 
				if ( flag >= 1 ) 
					{ 
					cputs ( "\rProgram aborted!  " ); 
					cout << "To many decimal points."; 
					exit ( 210 ); 
					} 
				flag = 1; 
				break; 
			case '-':	// Processes a negative 
 
				if ( nflag >= 1 ) 
					{ 
					cputs ( "\rProgram aborted!  " ); 
					cout << "To many minus signs."; 
					exit ( 211 ); 
					} 
				nflag = 1 ; 
				break; 
			case '+':	// Processes a plus sign 
				if ( pflag >= 1 ) 
					{ 
					cputs ( "\rProgram aborted!  " ); 
					cout << "To many minus signs."; 
					exit ( 212 ); 
					} 
				pflag = 1 ; 
				break; 
			default:	//  Take care of illegal character 
				cputs ( "\rProgram aborted!  " ); 
				cout << "Needs to be neumeric.  " 
				     << "\n\rNo alphabitic or other " 
				     << "characters allowd."; 
				exit ( 213 ); 
			} 
		} 
	if ( nflag == 0 )		// Return value rotine 
		return temp;		// Returns value with same sign 
	else 
		return temp * ( -1.0 );	// Returns value with changed sign 
	} 
 
/* 
This function is called by the conversion routine. 
*/ 
 
long double build ( long double ret_val, int no, int& flag ) 
	{ 
	long double temp; 
	temp = float ( no );	// Convert integer to floating point 
	if ( flag == 0 )	// Determine if left or right of decimal 
		{ 
		return ( ret_val * 10.0 ) + temp;	// Left of decimal 
		} 
	else 
		{ 
		for ( int n = 1; n <= flag; n ++ )	// Right of decimal 
			{ 
			temp /= 10.0; 
			} 
		flag ++; 
		return ret_val + temp;			// Returns value 
		} 
	} 
 
--- 
--- 
 * OFFLINE 1.58 
--- WILDMAIL!/WC v4.12 
---------------
* Origin: Star Tech Diamond Bar, CA 909-396-4227 714-257-1175 (1:218/801.0)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.