logo

Why d and f Are Used in the Format Codes for Integers and Real Numbers 📂Programing

Why d and f Are Used in the Format Codes for Integers and Real Numbers

Why d and f of All Things

20180409\_152729.png 1

In C, Python, and the like, the format codes used for inputting and outputting strings include %s, %c, %d, %f, and so on. As you know, %s denotes a string and %c denotes a character. However, unlike these that are taken from their initial letters, when writing integers and real numbers we use %d and %f rather than %i and %r.

The reason is that %d means not just an integer but decimal, and %f means float. Similarly, keep in mind that octal and hexadecimal are %o and %x, respectively.