#include "general.h"
#include <stdlib.h>
#include <string.h>
#include <iostream>

using namespace std;



Error::Error(char* Erm, int T)
{
	Type = T;
	strcpy(Message, Erm);
}


void Error::Report()
{
	cout << Message << '\n';
}


void Memory()
{
	THROW("Unable to allocate memory requested",4);
}

void LowerCase(char *s)
{
	for (uint i=0; i<strlen(s); i++) if (s[i]>='A' && s[i]<='Z') s[i]+=32;
}

void ftos(long double val, char* s, int Prec)
{
   char t[100];
   int d1,d2;
   strcpy(t,fcvt(val,Prec,&d1,&d2));
   if (d2) strcpy(s,"-");
   else strcpy(s,"");
   if (d1>0)
   {
      for (d2=strlen(t)+1; d2>=d1; d2--) t[d2+1]=t[d2];
      t[d1]='.';
      strcat(s,t);
   }
   else
   {
      strcat(s,"0.");
      for (d2=0; d2<-d1; d2++) strcat(s,"0");
      strcat(s,t);
   }
}


