text: /**
   * HiSER (c)2018 Litvin Artem Vasilyevich
   * Date 27.08.2019
   * hiser@mail.ru, +79130258565
   * License MIT
   */
  
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <stdlib.h>
  #include <stdio.h>
  #include <reent.h>
  #include <math.h>
  
  char* dtoa(char* dest, double value, int digit)
  {
  	char* fmt;
  	int i = 0, p = 0;
  	double n, m;
  	if (dest == NULL) dest = (char*)malloc(24);
  	if (digit < 0 || digit > 6) digit = 6;
  	if (value < 0)
  	{
  		value = -value;
  		dest[0] = '-';
  		p = 1;
  	}
  	if (isnan(value) != 0)
  	{
  		sprintf(&dest[p], "NaN");
  	}
  	else if (isinf(value) != 0)
  	{
  		sprintf(&dest[p], "Infinite");
  	}
  	else
  	{
  		m = modf(value, &n);
  		p += sprintf(&dest[p], "%u", (unsigned int)n);
  		while (modf(m, &n) > 0.0000001 && i < digit)
  		{
  			m *= 10;
  			i++;
  		}
  		m = floor(m);
  		if (i > 0 && m > 0)
  		{
  			fmt = (char*)malloc(16);
  			sprintf(fmt, ".%%%02uu", i);
  			sprintf(&dest[p], fmt, (unsigned int)m);
  			free(fmt);
  		}
  	}
  	return dest;
  }
  
  
  double atod(const char* src)
  {
  	double value = atof(src);
  	return value;
  }
  