Skip to content

Instantly share code, notes, and snippets.

View rakesh-ideal's full-sized avatar

Rakesh rakesh-ideal

View GitHub Profile
@rakesh-ideal
rakesh-ideal / fraction.c
Created June 21, 2018 09:15
Fraction value
char *userTextForDouble(double d, char *rval)
{
if (d == 0.0)
return "0";
// TODO: negative numbers:if (d < 0.0)...
if (d >= 1.0)
sprintf(rval, "%.0f ", floor(d));
d = d-floor(d); // now only the fractional part is left