CT-NG: floating point support in Newlibs printf?
Jeppe Ledet-Pedersen
jledet@space.aau.dk
Thu Oct 21 10:55:00 GMT 2010
Hi
I have successfully compiled a toolchain for my ARM7TDMI with
crosstool-NG 1.8.1. I have used GCC 4.5.0, Newlib 1.18 and Binutils
2.20.1, disabled EABI and software floating point. The full
build.log.bz2 can be downloaded from http://kom.aau.dk/~jledet/build.log.bz2
I can compile my codebase with no errors, but I am having trouble when
trying to use printf and siblings with floating point values. Everything
else, including printf's with integers, seems to work as expected. With
a simple test code like this:
void float_test(void) {
double a, b;
int result;
a = 12.8;
b = 35.2;
result = (int) (b / a);
printf("a is %f\r\n", a);
printf("b is %f\r\n", b);
printf("b / a = %d\r\n", result);
}
My output is:
a is -0.000000
b is -0.000000
b / a = 2
So the calculations appear to be correct, but the floating point output
is obviously wrong.
If I try to use e.g. %.1f in my format string, newlib calls sbrk with a
~1 GiB increment and my system naturally crashes.
I have tried to enable EABI, but I face the same problem. As far as I
can figure out, newlib does support floating point values in printf, if
not explicitly disabled, but I see no trace of this in the build log.
Any good advice on what I should do? The help is really appreciated. If
you need additional information, just let me know.
Thank you in advance.
/Jeppe
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list