/*
QtWagon: a project about 3D objects.
Science and technology promotion license applied. Third party license automatically cascaded.
Zhikai Wang/ www.heteroclinic.net 2013
You can do anything with this file or any file(s) published as part QtWagon project, given this header is kept.
*/
#include "to_string.h"
int getWidth (int d) {
	int i = 0; 
	d = abs(d);
	if (0==d)
		return 1;
	while ( d >0 ) {
		d /= 10;
		++i;
	}
	return i;
}
const std::string getFormatedIntegerString (int d, int a,char c) {// it is required |a|>=|d|
	std::stringstream ss;
	ss << std::setw(getWidth(a))<<std::setfill(c) <<d;
	return ss.str();
}
const std::string formatDouble (double d, int precision_len ) {
	std::stringstream ss;
	ss<<std::showpos<<std::fixed<<std::scientific <<std::setprecision(precision_len)<<d;
	//	std::cout<<ss3.str()<<std::endl;
	return ss.str();
}