stdio/format: fix printing sign for long double#487
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates stdio/format.c to preserve the sign bit when downconverting a long double to a double during floating-point formatting. It introduces an msb parameter to format_sprintfDouble to pass the sign bit. A review comment correctly points out that checking the sign bit with __builtin_signbit(doubleNumber) > 0 is unsafe, as the function is only guaranteed to return a non-zero value which could be negative on some platforms. It is recommended to use != 0 instead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
b3bfc24 to
af61ddc
Compare
af61ddc to
65b9b02
Compare
JIRA: RTOS-1368
65b9b02 to
3bcf8eb
Compare
JIRA: RTOS-1368
Description
When down-converting from long double to double on RISCV, GCC is emitting
__trunctfdf2()which truncates sign bit for special values (NaN, inf). This fix preservers sign bit before down-convertion, and adds it later when needed.Motivation and Context
Fixes phoenix-rtos/phoenix-rtos-project#1007
Types of changes
How Has This Been Tested?
Checklist:
Special treatment