Skip to content

Instantly share code, notes, and snippets.

@mouuff
Created May 25, 2016 18:55
Show Gist options
  • Save mouuff/7f23520d71f28a7a716dca010a472066 to your computer and use it in GitHub Desktop.
Save mouuff/7f23520d71f28a7a716dca010a472066 to your computer and use it in GitHub Desktop.
void my_putnbr(unsigned int nb)
{
unsigned int x;
x = 1;
while ((nb / (x * 10)) > 0)
x *= 10;
while (x > 0)
{
my_putchar((nb / x) % 10 + '0');
x /= 10;
}
}
void my_putfloat(float fl)
{
float dec;
if (fl < 0)
{
fl *= -1;
my_putchar('-');
}
my_putnbr((int)fl);
my_putchar('.');
dec = (fl - (int)fl);
while ((float)((int)dec) != dec)
{
dec *= 10;
if ((int)dec == 0)
my_putchar('0');
}
my_putnbr((int)dec);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment