Hi, I've trying to convert some floats using for a pic16 device and I've been unable to make work any of the supplied routines, I'm using a pic 8722, stack and memory model large and I test the routines (because I don't know how to make the work) with the following code that test different values and presicions :
uchar i,p; char buff[20]; float d[5]; d[0]=1.23456; d[1]=2.34567; d[2]=3.45678; d[3]=4.56789; d[4]=5.67890; for (i=0;i<5;i++){ for(p=0;p<20;p++){ send_str("Valor "); send_uchar(i); send_str(" precision "); send_uchar(p); //x_ftoa(d[i],buff,19,p); g_ftoa(buff,d[i],p); send_str(" = "); buff[19]=0; send_str(buff); send_nl(); } } I get only weird numbers with any value in the precision field as can be shown in the following listing : Valor 0 precision 1 = 0.06666722666666666 Valor 0 precision 2 = 0.06666723333333333 Valor 0 precision 3 = 0.07222257333333333 Valor 0 precision 4 = 0.07666724444444444 Valor 0 precision 5 = 0.07333373555555555 Valor 0 precision 6 = 0.06777852666666666 Valor 0 precision 7 = 0.07555655111111111 Valor 0 precision 8 = 0.07111151111111111 Valor 0 precision 9 = 0.07444485111111111 Valor 0 precision 10 = 0.00015611555555555 Valor 0 precision 11 = 0.00016047777777777 Valor 0 precision 12 = 0.00016502222222222 Valor 0 precision 13 = 0.00016500444444444 Valor 0 precision 14 = 0.00016724666666666 Valor 0 precision 15 = 0.00017233111111111 Valor 0 precision 16 = 0.00017367333333333 Valor 0 precision 17 = 0.00017611555555555 Valor 0 precision 18 = 0.00020043777777777 Valor 0 precision 19 = 0.00020614222222222 Valor 1 precision 0 = 0.07555611111111111 Valor 1 precision 1 = 0.06777833777777777 Valor 1 precision 2 = 0.07556124222222222 Valor 1 precision 3 = 0.07111146222222222 Valor 1 precision 4 = 0.07444482222222222 Valor 1 precision 5 = 0.06777836222222222 Valor 1 precision 6 = 0.07333372222222222 Valor 1 precision 7 = 0.07777837333333333 Valor 1 precision 8 = 0.07444484444444444 Valor 1 precision 9 = 0.07111153555555555 ....... I've seen in the manual that to have printf with float support I have to recompile with '-DUSE_FLOATS=1', I've tried to add it to configure scripts and Makefiles without success. Can some of the masters give a hand ? Olgierd Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user