URL: <http://savannah.nongnu.org/bugs/?43442>
Summary: sprintf function incorrectly interprets format parameters Project: AVR C Runtime Library Submitted by: None Submitted on: Sun 19 Oct 2014 10:00:12 PM UTC Category: Library Severity: 3 - Normal Priority: 5 - Normal Item Group: libc code Status: None Percent Complete: 0% Assigned to: None Originator Email: wojciec...@outlook.com Open/Closed: Open Discussion Lock: Any Release: 1.8.0 Fixed Release: None _______________________________________________________ Details: Function sprintf incorrectly interprets passed parameters, on following example: char someString[3]; uint8_t number = 0; number = 9; sprintf(someString, "%02u", number); Now in someString we will have 09 but when we do this: number = 10; sprintf(someString, "%02u", number); Then in someString we have 16, not 10 as we expect. But when we change format from "%02u" to "%02x" then it works fine, and we have 10 in someString. Of course with values 20, 30 and so on problem also exist. From what I can see, this function interpret %u as hex(10 in HEX is 16 in DEC) and %x as decimal but it should be interpreted inversely. _______________________________________________________ Reply to this item at: <http://savannah.nongnu.org/bugs/?43442> _______________________________________________ Message sent via/by Savannah http://savannah.nongnu.org/ _______________________________________________ AVR-libc-dev mailing list AVR-libc-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-libc-dev