If I use a whole number in #define
, what data type
is it considered to be in sprintf()
in C99
?
#define NUMBER 100
sprintf(buf, "%i\n", NUMBER); // is it %i, %u, %lu ?
Decimal Data Type. The decimal data type is an exact numeric data type defined by its precision (total number of digits) and scale (number of digits to the right of the decimal point).
Integers – This value is represented by int class. It contains positive or negative whole numbers (without fraction or decimal). In Python there is no limit to how long an integer value can be.
#define NUMBER1 100 /* int: use "%d" or "%i" in printf() */
#define NUMBER2 100U /* unsigned int: use "%u" in printf() */
#define NUMBER3 100L /* long int: use "%ld" or "%li" in printf() */
#define NUMBER4 100UL /* unsigned long int: use "%lu" in printf() */
/* C99 */
#define NUMBER5 100LL /* long long int: use "%lld" or "%lli" in printf() */
#define NUMBER6 100ULL /* unsigned long long int: use "%llu" in printf() */
Note: the U and L can also be in lowercase
Note2: the U can come before or after the L or LL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With