Community
Participate
Working Groups
The following code: #include <xdc/std.h> #include <xdc/runtime/System.h> Void main() { System_printf("%5.2f\n", 0.78125 * 0.34); System_printf("%7.2f\n", 0.78125 * 0.34); } should print 0.27 0.27 but it prints 00.2656 00.2656 instead. It doesn't matter if SysMin or SysStd is used. The bug is initially reported here: http://e2e.ti.com/support/embedded/f/355/p/142976/532090.aspx#532090.
fixed by adding changes to the System.c and System.xdt. But the fractional part is fixed at 4 in System_printf to make it fast. #include <xdc/std.h> #include <xdc/runtime/System.h> Void main() { System_printf("%5.2f\n", 0.78125 * 0.34); System_printf("%7.2f\n", 0.78125 * 0.34); } now prints 0.2656 0.2656
fixed in xdc-z04
- verified with XDCtools 3.25.00.40 The original example uses the field width of 5, which is a minimum width. Since we always print four digits after the decimal point, the output is already wider than five characters. The test stdout.precision in the xdctest tree already verifies the case with 5.2f and then 7.2f format strings. I tried System_printf("%9.2f\n", 0.78125 * 0.34); System_printf("%7.2f\n", 0.78125 * 0.34); and the result was 0.2656 0.2656 as expected. Also, adding '0' as a padding character worked fine: System_printf("%09.2f\n", 0.78125 * 0.34); System_printf("%07.2f\n", 0.78125 * 0.34); output: 0000.2656 00.2656
shipped in 3.25.00.48: http://downloads.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/rtsc/3_25_00_48/index_FDS.html.