/**
 * CHaotic Arithmetics O Shit  version 0.666
 * This is one of the most boring programs I've ever written.
 * It expects two floating-point numbers as arguments. Each argument is
 * doubled 30 times, (only the fractional part) that is. The results 
 * are anything but amazing. Won't explain more, I can't believe I'm writing
 * this. 
 * 
 * To compile use your favorite ISO-C++ compliant compiler. 
 * No GUI, no nothing. Not even meaningful identifiers. 
 * In fact, you must be outa your mind to have downloaded this. 
 * Adding a license would clearly count as hubris. 
 * Have fun(?)... yeah right!
 */

#include <iostream>
#include <sstream>
#include <algorithm>

//this doubles its argument and throws away the integral part of the 
//result
double special_double(double d){
	double duplicated = d*2;
	int integral_part = duplicated;
	return duplicated - integral_part;
}

//hope I don't have to explain THAT...
double percentage(double d1, double d2){
	using std::min;
	using std::max;
	return 100*(
		(max(d1,d2)-min(d1,d2))/min(d1,d2)
	);
}

int main(int argc, char ** argv){
	using namespace std;
	
	if (argc < 3){
		cerr<<"Usage: "<< argv[0] << " number1 number2\n";
		return -1;
	}

	double d1, d2;
	istringstream is(argv[1]);
	is>>d1;
	istringstream is2(argv[2]);
	is2>>d2;
	
	double d1_orig=d1;
	double d2_orig=d2;
	
	for (int i=0; i<30; i++){
		d1 = special_double(d1);
		d2 = special_double(d2);
	}

	cout<<"Original numbers: "<<d1_orig<<"\t"<<d2_orig<<"\n";
	cout<<"Result after 30 'duplications':"<<d1<<"\t"<<d2<<"\n";
	cout<<"Initial difference (%):"<<percentage(d1_orig, d2_orig)<<"\n";
	cout<<"Resulting difference (%):"<<percentage(d1, d2)<<"\n";
}

