Printf-style formatting is a fundamental string operation used across C, C++, Python (% operator and old-style formatting), Java (String.format), PHP, Ruby, and many other languages. Understanding format specifiers lets you control precisely how numbers, strings, and other values are displayed.
%s — string%d or %i — signed decimal integer%f — decimal floating point (default 6 decimal places)%.2f — float with exactly 2 decimal places%e — scientific notation (e.g., 1.23e+04)%x — lowercase hexadecimal integer%X — uppercase hexadecimal integer%o — octal integer%% — literal percent sign%.2f formats a floating-point number with exactly 2 decimal places. The 0 flag (as in %05.2f) adds zero-padding to reach the specified minimum width. Example: printf('%05.2f', 3.1) → '03.10'.
This tool implements the classic C-style % formatting that is also used in Python's old-style string formatting (e.g. 'Hello %s' % 'World'). Python's newer f-strings and str.format() use different syntax.