-- }
-- }
-+ char buf[101];
-+ std::snprintf(buf, 100, "%.20g", d);
++
++ // The nubmer of digits right of '.'
++ int respartsize = maxdigits-intpartsize;
++ if( respartsize < 0 )
++ respartsize = 0;
++
++ // Building the format string and get the string conversion of d
++ char fmt[256];
++ snprintf(fmt, 255, "%%%d.%df", intpartsize, respartsize);
++ snprintf(buf, bufsize, fmt, d);
++
++
++ // Truncate redundant zeros and '.' from the right
++ for(int i = strlen(buf)-1; i>=intpartsize; i--)
++ {
++ // Truncate all zeros from right-hand
++ if( buf[i] == '0' )
++ {
++ buf[i] = '\0';
++ continue;
+ }
++
++ // Remove decimal dot without decimal digits
++ if( buf[i] == '.' )
++ buf[i] = '\0';
++
++ break;
+ }
++
++