[En-Nut-Discussion] Float problem

Ole Reinhardt ole.reinhardt at kernelconcepts.de
Fri Oct 29 17:06:55 CEST 2004


Hi,

> float tall=100;
> char f[10];
> 
> tall=tall/6;
> 
> printf("%f",tall");  /// PRINTER OUT 16.66666

if you link to libnutcrtf you can use:

sprintf(f, "%8.5f", tall);

If you don't, try:

t[0] = '0'+(tall / 10) % 10;
t[1] = '0'+(tall % 10);
t[2] = '.';
t[3] = '0'+(tall * 10) % 10;
t[4] = '0'+(tall * 100) % 10;
...

Ole


-- 
kernel concepts    Tel: +49-271-771091-14
Dreisbachstr. 24   Fax: +49-271-771091-19
D-57250 Netphen    E+ : +49-177-7420433
--





More information about the En-Nut-Discussion mailing list