Here a solution is possible:
typedef enum
{
DEC1 = 10,
DEC2 = 100,
DEC3 = 1000,
DEC4 = 10000,
DEC5 = 100000,
DEC6 = 1000000,
} tPrecision ;
void putFloat( float f, tPrecision p )
{
long i = (long)f ;
putLong( i ) ;
f = (f - i) * p ;
i = abs((long)f) ;
if( fabs(f) - i >= 0.5f )
{
i++ ;
}
putchar('.') ;
putLong( i ) ;
putchar('\n') ;
}
You would use it this way:
putFloat( 3.14159f, DEC3 ) ;
which will output "3.142", note the rounding of the third digit.
, .
, 6 , . , , , 123.456, DEC6, . 6- , , , .