| Anonymous | Login | Signup for a new account | 11-10-2008 11:01 PST |
| Main | My View | View Issues | Change Log | Docs |
| 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 | |||||||||
|
|
|||||||||
| Copyright © 2000 - 2006 Mantis Group |