Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 806 Bytes

File metadata and controls

31 lines (20 loc) · 806 Bytes

Printf integer with commas

Simple C-Language utility to add commas to large integer values when printing from printf, e.g.

standard printf output :-
total bytes=7580677 used bytes=2535702

with commas printf output :-
total bytes=7,580,677 used bytes=2,535,702

Two versions are offered here

1. void printf_uint_commas(uint unsigned_integer);

prints the supplied uint in comma-formatted style to stdio.

2. void snprintf_uint_commas(uint unsigned_integer, char printf_result[14U]);

populates the printf_result buffer with comma-formatted result;

developer can then use a regular printf to output the result.

Initial testing with Raspberry Pico SDK only.

Note that printf implementations can and do vary between platforms, and further testing is therefore recommended.