PRINTF (DbgConsole_Printf) doesn't work for negative float

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PRINTF (DbgConsole_Printf) doesn't work for negative float

956 Views
blmckinley
Contributor II

Using MCUXpresso 
Product: MCUXpresso IDE
Version: MCUXpresso IDE v24.12 [Build 148] [2025-01-10]
Operating system: Windows 11
VM: OpenJDK 64-Bit Server VM (64 bit)

The PRINTF macro that resolves to DbgConsole_Printf is supposed to provide small, lightweight print to terminal features. But it does not print negative float values correctly. This is apparently a known issue but it took me 2 solid days of fooling around with my code trying to figure out why my values had the wrong sign. 

The solution proposed in https://community.nxp.com/t5/MCUXpresso-SDK/Printing-negative-floats-with-DbgConsole-Printf-in-mcuxp...
is not really adequate since stdio brings in all kinds of other libraries and expands the amount of flash memory required. That is the whole reason that the SDK even provides a lightweight print function.

So it is really NOT a good solution, and the issue should remain open. How is it that this bug still exists in the SDK after TWO entire years? This is a ridiculously straightforward problem to solve. Please fix the SDK and stop wasting your developers' valuable time.


0 Kudos
Reply
3 Replies

790 Views
mayliu1
NXP Employee
NXP Employee

Hi @blmckinley ,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.

I suggest you can refer to this NXP community post:

Solved: Printing negative floats with DbgConsole_Printf in mcuxpresso SDK 2.15 - NXP Community

Please try it.

Best Regards

MayLiu

0 Kudos
Reply

763 Views
blmckinley
Contributor II
Thank you for the reply. As I mention in my post, although the printf() function does work for negative numbers, that is not a solution for a bug in the SDK function DbgConsole_Printf().

Your users deserve bug-free SDKs and I highly recommend you fix the bug as outlined.
0 Kudos
Reply

647 Views
mayliu1
NXP Employee
NXP Employee

Hi @blmckinley ,

Thanks for your feedback, I have already created an internal ticket for your question.

Best Regards

May Liu

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2303138%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EPRINTF%20%20(DbgConsole_Printf)%20doesn't%20work%20for%20negative%20float%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2303138%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EUsing%20MCUXpresso%26nbsp%3B%3CBR%20%2F%3EProduct%3A%20MCUXpresso%20IDE%3CBR%20%2F%3EVersion%3A%20MCUXpresso%20IDE%20v24.12%20%5BBuild%20148%5D%20%5B2025-01-10%5D%3CBR%20%2F%3EOperating%20system%3A%20Windows%2011%3CBR%20%2F%3EVM%3A%20OpenJDK%2064-Bit%20Server%20VM%20(64%20bit)%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20PRINTF%20macro%20that%20resolves%20to%26nbsp%3BDbgConsole_Printf%20is%20supposed%20to%20provide%20small%2C%20lightweight%20print%20to%20terminal%20features.%20But%20it%20does%20not%20print%20negative%20float%20values%20correctly.%20This%20is%20apparently%20a%20known%20issue%20but%20it%20took%20me%202%20solid%20days%20of%20fooling%20around%20with%20my%20code%20trying%20to%20figure%20out%20why%20my%20values%20had%20the%20wrong%20sign.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20solution%20proposed%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FMCUXpresso-SDK%2FPrinting-negative-floats-with-DbgConsole-Printf-in-mcuxpresso%2Fm-p%2F1795964%23M4587%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FMCUXpresso-SDK%2FPrinting-negative-floats-with-DbgConsole-Printf-in-mcuxpresso%2Fm-p%2F1795964%23M4587%3C%2FA%3E%3CBR%20%2F%3Eis%20not%20really%20adequate%20since%20stdio%20brings%20in%20all%20kinds%20of%20other%20libraries%20and%20expands%20the%20amount%20of%20flash%20memory%20required.%20That%20is%20the%20whole%20reason%20that%20the%20SDK%20even%20provides%20a%20lightweight%20print%20function.%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20it%20is%20really%20NOT%20a%20good%20solution%2C%20and%20the%20issue%20should%20remain%20open.%20How%20is%20it%20that%20this%20bug%20still%20exists%20in%20the%20SDK%20after%20TWO%20entire%20years%3F%20This%20is%20a%20ridiculously%20straightforward%20problem%20to%20solve.%20Please%20fix%20the%20SDK%20and%20stop%20wasting%20your%20developers'%20valuable%20time.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2333210%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PRINTF%20%20(DbgConsole_Printf)%20doesn't%20work%20for%20negative%20float%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2333210%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F232320%22%20target%3D%22_blank%22%3E%40blmckinley%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EThank%20you%20for%20your%20interest%20in%20NXP%20Semiconductor%20products%20and%20for%20the%20opportunity%20to%20serve%20you.%3C%2FP%3E%0A%3CP%3EI%20suggest%20you%20can%20refer%20to%20this%20NXP%26nbsp%3B%3CSPAN%3Ecommunity%20post%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FMCUXpresso-SDK%2FPrinting-negative-floats-with-DbgConsole-Printf-in-mcuxpresso%2Ftd-p%2F1795380%22%20target%3D%22_blank%22%3ESolved%3A%20Printing%20negative%20floats%20with%20DbgConsole_Printf%20in%20mcuxpresso%20SDK%202.15%20-%20NXP%20Community%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EPlease%20try%20it.%3C%2FP%3E%0A%3CP%3EBest%20Regards%3C%2FP%3E%0A%3CP%3EMayLiu%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2334110%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PRINTF%20%20(DbgConsole_Printf)%20doesn't%20work%20for%20negative%20float%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2334110%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EThank%20you%20for%20the%20reply.%20As%20I%20mention%20in%20my%20post%2C%20although%20the%20printf()%20function%20does%20work%20for%20negative%20numbers%2C%20that%20is%20not%20a%20solution%20for%20a%20bug%20in%20the%20SDK%20function%20DbgConsole_Printf().%3CBR%20%2F%3E%3CBR%20%2F%3EYour%20users%20deserve%20bug-free%20SDKs%20and%20I%20highly%20recommend%20you%20fix%20the%20bug%20as%20outlined.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2342004%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PRINTF%20%20(DbgConsole_Printf)%20doesn't%20work%20for%20negative%20float%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2342004%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F232320%22%20target%3D%22_blank%22%3E%40blmckinley%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EThanks%20for%20your%20feedback%2C%20I%20have%20already%20created%20an%20internal%20ticket%20for%20your%20question.%3C%2FP%3E%0A%3CP%3EBest%20Regards%3C%2FP%3E%0A%3CP%3EMay%20Liu%3C%2FP%3E%3C%2FLINGO-BODY%3E