// safkoUtils.h

#ifndef SAFKOUTILS_H
#define SAFKOUTILS_H

#include <iostream>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

// Uncomment this line if you put more functions here
//string dtos(double num, int precision);


string dtos(double num, int precision)
{
	string final;
	string dec = "";
	char whole[80];
	char decimal[80];

	// capture the whole number portion
	int wholeNum = static_cast<int> (num);
	unsigned long double deciNum = fabs(num - wholeNum);
	itoa(wholeNum, whole, 10);

	// capture the decimal portion
	// multiply by 10, capture this single digit to the left
	// of the decimal, and store that digit to a character array
	// Append that array to a string. Repeat for the length of your precision

	for(int x = 0; x < precision; x++)
	{
		deciNum *= 10;
		itoa(static_cast<int>(deciNum), decimal, 10);
		dec += decimal;
		deciNum -= static_cast<int> (deciNum);
	}

	// now, build the number to string object
	final = whole;
	final += ".";
	final += dec;
	
	return final;

}


#endif
