Created
May 25, 2016 18:55
-
-
Save mouuff/7f23520d71f28a7a716dca010a472066 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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