Eric_O
Advanced Member level 4
Here under the subroutine in MikroC :
Merci !
Code:
void print_float_v4(char *flt, long number, char decimals)
{
if (number < 0)
{
number = - number;
*(flt) = '-';
}
else
{
*(flt) = ' ';
}
*(flt + 1) = ' ';
if (decimals == 2)
{
*(flt + 2) = number / 1000000 + 48;
*(flt + 3) = ((number % 1000000) / 100000) + 48;
*(flt + 4) = ((number % 100000) / 10000) + 48;
*(flt + 5) = ((number % 10000) / 1000) + 48;
*(flt + 6) = ((number % 1000) / 100) + 48;
*(flt + 7) = ((number % 100) / 10) + 48;
*(flt + 8) = ((number % 10) / 1) + 48;
*(flt + 9) = ',';
*(flt + 10) = ((number % 100) / 10) + 48;
*(flt + 11) = (number % 10) + 48;
*(flt + 12) = 0;
}
else
{
*(flt + 2) = number / 100000 + 48;
*(flt + 3) = ((number % 100000) / 10000) + 48;
*(flt + 4) = ((number % 10000) / 1000) + 48;
*(flt + 5) = ((number % 1000) / 100) + 48;
*(flt + 6) = ((number % 100) / 10) + 48;
*(flt + 7) = ',';
*(flt + 8) = (number % 10) + 48;
*(flt + 9) = 0;
}
if (*(flt + 2) == '0') // Suppression des zéros inutiles.
{
*(flt + 2) = ' ';
if (*(flt + 3) == '0')
{
*(flt + 3) = ' ';
if (*(flt + 4) == '0')
{
*(flt + 4) = ' ';
if (*(flt + 5) == '0')
{
*(flt + 5) = ' ';
if (*(flt + 6) == '0')
{
*(flt + 6) = ' ';
if (*(flt + 7) == '0')
{
*(flt + 7) = ' ';
}
}
}
}
}
}
}
Merci !