BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000845 [uClibc] Architecture Specific major always 04-21-06 09:30 10-06-06 23:02
Reporter james View Status public  
Assigned To uClibc
Priority normal Resolution unable to reproduce  
Status closed   Product Version 0.9.28
Summary 0000845: uClibc Floating Point Bug with all Print Functions
Description We have identified a bug with the uClibc library used with an ARM core processor. Floating point numbers under Note: 0000011.0 with certain formating flags do not print with printf. The one I am using is a 6 character width and 2 digit precision on a floating point number.

For example:
ret = printf("%6.2f\n", 15.0); /* prints " 15.00", ret = 7 */
ret = printf("%6.2f\n", 10.0); /* prints " 1", ret = 0, should be "
10.00"
*/
ret = printf("%6.2f\n", 5.0); /* prints "", ret = 0, should be " 5.00"
*/

This happens with the entire family of printf (sprintf, fprintf, etc)
that uses the vfprintf library calls.

A customer of ours has also identified this problem: We have the same problem with all powers of 10 (100.0, 1000.0, 10000.0,
....).
Additional Information At the moment, our workaround for sprintf("%6.2f", num) is:

#ifdef UCLIBC_FLOAT_BUG
/* size is always 6 */
size = 6;
if (num == 0.0)
/* avoid NWFPE exception */
strcpy(string, " 0.00");
else if (num > 12.0)
{
/* returned argument is always zero, so we don't use it */
sprintf(string, "%6.2f", num);
}
else
{
/* round 0.01 digit if needed */
if (((int)(num * 1000.0) % 10) >= 5)
num += 0.01;
string[0] = ' ';
if (num < 10.0)
string[1] = ' ';
else
string[1] = '1';
string[2] = ((int)num % 10) + '0';
string[3] = '.';
string[4] = ((int)(num * 10.0) % 10) + '0';
string[5] = ((int)(num * 100.0) % 10) + '0';
string[6] = '\0';
}
#else
size = sprintf(string, "%6.2f", num);
#endif

It seems to work within the range of numbers we deal with (+0.00 ->
+200.00).
Attached Files

- Relationships

- Notes
(0001319)
vapier
04-21-06 14:49

$ cat test.c
#include <stdio.h>
#define it(f) printf("%s ", #f); printf(" ret: %i\n", printf("%6.2f", f));
int main() {
it(15.0) it(10.0) it(5.0)
}
$ gcc test.c && ./a.out
15.0 15.00 ret: 6
10.0 10.00 ret: 6
5.0 5.00 ret: 6
$ gcc -fno-builtin test.c && ./a.out
15.0 15.00 ret: 6
10.0 10.00 ret: 6
5.0 5.00 ret: 6

works just fine for me on arm/uclibc-0.9.28 ... tested little endian hardfloat and big endian softfloat with gcc-3.3.4 and gcc-3.4.5
 

- Issue History
Date Modified Username Field Change
04-21-06 09:30 james New Issue
04-21-06 09:30 james Status new => assigned
04-21-06 09:30 james Assigned To  => uClibc
04-21-06 14:49 vapier Note Added: 0001319
04-21-06 14:49 vapier Status assigned => resolved
04-21-06 14:49 vapier Resolution open => unable to reproduce
10-06-06 23:02 vapier Status resolved => closed


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker