Use the ll (el-el) long-long modifier with the u (unsigned) conversion. (Works in windows, GNU).

printf("%llu", 285212672);
Answer from John Downey on Stack Overflow
🌐
Wyzant
wyzant.com › resources › ask an expert
How do you format an unsigned long long int using printf? | Wyzant Ask An Expert
May 3, 2019 - #include <stdio.h> int main() { unsigned long long int num = 285212672; //FYI: fits in 29 bits int normalInt = 5; printf("My number is %d bytes wide and its value is %ul. A normal number is %d.\\n", sizeof(num), num, normalInt); return 0; }Output: My number is 8 bytes wide and its value is 285212672l.
Discussions

Printf, sprintf unsigned long
I have following test code: vector ... %.2f\n",(unsigned long)i,sensorData[TEMP],sensorData[PRESS],sensorData[HUM]); Serial.printf( "Test: Time: %6l, Temp: %.2f, Press: %.2f, Hum: %.2f\n",(unsigned long)i,sensorData[TEMP],sensorData[PRESS],sens...... More on forum.arduino.cc
🌐 forum.arduino.cc
4
0
June 21, 2024
printf unsigned long long as hex
Hi, printf's format specifier %X only prints values of up to 8 hex digits. I am using GCC on Gentoo Linux. (How do I find which GCC version I have?) Is it possible to print values as hex up to 15 or 16 hex digits? If not, a workaround would be appreciated also. TIA More on thecodingforums.com
🌐 thecodingforums.com
5
July 2, 2007
Why is unsigned long long int behaving as int?
%u means: print an unsigned integer. Only an unsigned integer will be consumed from the input to printf. This is disjoint from what is actually going on within i. So: all modern compilers should give you a warning here; and check out %llu. More on reddit.com
🌐 r/C_Programming
8
18
November 16, 2023
how to do printf with unsigned short long data type?
Loading · ×Sorry to interrupt · Refresh More on forum.microchip.com
🌐 forum.microchip.com
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Printf, sprintf unsigned long - Programming - Arduino Forum
June 21, 2024 - I have following test code: vector ... %.2f\n",(unsigned long)i,sensorData[TEMP],sensorData[PRESS],sensorData[HUM]); Serial.printf( "Test: Time: %6l, Temp: %.2f, Press: %.2f, Hum: %.2f\n",(unsigned long)i,sensorData[TEMP],sensorData[PRESS],sens......
🌐
The Coding Forums
thecodingforums.com › archive › archive › c programming
printf unsigned long long as hex | C Programming | Coding Forums
July 2, 2007 - The format for printing an unsigned long long value in 16 hexadecimal digits, with leading zeros as needed, is "016llx" (that's zero one six ell ell ex for those reading with fonts that don't distinguish between '1' and 'l'). But this will work ...
🌐
Reddit
reddit.com › r/c_programming › why is unsigned long long int behaving as int?
r/C_Programming on Reddit: Why is unsigned long long int behaving as int?
November 16, 2023 -

For the purpose of the code, the thing I wanna understand is why it goes like this:

include <limits.h>

unsigned long long int i;

for (i = 1; i < ULLONG_MAX / 10; i *= 10) {

printf(“%u\n”, i);

}

This thing prints:

1

10

100

1000

10000

100000

1000000

10000000

100000000

1000000000

1410065408

1215752192

3567587328

It looks like it’s overflowing around 10 billions, so I wonder if it somehow casted it as a normal int instead of an unsigned long long int. In the code I need it to multiply for an ever increasing number, until I hit the ceiling being ULLONG_MAX, but I don’t know why it behaves like this; something’s wrong with my rig? I’m running this code on a virtual box with Linux, my rig is 64 bit.

Any help is appreciated

Find elsewhere
🌐
Quora
quora.com › How-can-I-print-an-unsigned-long-int-in-C-language
How to print an unsigned long int in C language - Quora
Answer (1 of 6): %lu is the standard order for unsigned long int. Just ran this snippet and it works for me. #include int main(void) { int unsigned long number = 600851475143LU; printf( "%lu", number ); return 0; } Let me know if you face some issue with this Vineeta Karki.
🌐
LinuxQuestions.org
linuxquestions.org › questions › programming-9 › printf-unsigned-long-long-int-274423
printf unsigned long long int?
how do I printf an unsigned long long int( aka uint64_t ). %s for string %??? for unsigned long long int?
🌐
NXP
community.nxp.com › t5 › MCUXpresso-General › printf-double-and-unsigned-long-int-support › td-p › 967954
printf(), double and unsigned long int support - NXP Community
June 28, 2019 - where i is declared as uint64_t cast as an unsigned long int equal to 0x100000001 displays as "i = lu". If instead I select Newlib (nohost) in the Library/Header category, the second printf() call shown above will render the expected value, however when the first printf() shown is encountered the hard fault handler is inevitably invoked.
🌐
Unstop
unstop.com › home › blog › format specifiers in c — complete list with code examples (2026)
Format Specifiers in C — Complete List with Code Examples (2026)
May 19, 2026 - The %lu format specifier is used to print unsigned long integers in C. An unsigned long integer is a non-negative integer that typically occupies more memory than a standard unsigned int, allowing it to represent a larger range of values.
🌐
Wyzant
wyzant.com › resources › ask an expert
How to printf "unsigned long" in C? | Wyzant Ask An Expert
April 18, 2019 - printf("%llu\n", foo); // unsigned long long (have to put the ll first, then u for unsigned long long)
🌐
w3resource
w3resource.com › c-programming-exercises › c-snippets › conversion-specifier-for-formatting-long-with-printf-in-c.php
Conversion Specifier for Printing long in C with printf
For printing a long integer, you use the %ld specifier. This specifier tells printf to format the corresponding argument as a long int. For unsigned long values, use %lu.
🌐
W3Schools
w3schools.com › c › c_data_types_extended.php
C More Data Types (Extended Types)
May 17, 2026 - printf("Size of int: %zu bytes\n", sizeof(int)); printf("Size of double: %zu bytes\n", sizeof(double)); printf("Size of short int: %zu bytes\n", sizeof(short int)); printf("Size of unsigned int: %zu bytes\n", sizeof(unsigned int)); printf("Size ...
🌐
Texas Instruments E2E
e2e.ti.com › support › microcontrollers › msp-low-power-microcontrollers-group › msp430 › f › msp-low-power-microcontroller-forum › 199047 › printf-unsigned-long-int-a
printf unsigned long int a; - MSP low-power microcontroller forum - MSP low-power microcontrollers - TI E2E support forums
This has nothing to do with MSP430. The printf implementation is a plain compiler-specific thing. A different compiler (and there are at tlest three I know of) may handle it differently. Even the support for different levels of printf support is not MSP specific.
🌐
Texas Instruments E2E
e2e.ti.com › support › tools › code-composer-studio-group › ccs › f › code-composer-studio-forum › 695304 › ccs-how-to-print-unsigned-long-long-uint64_t-using-system_printf-and-system_flush
CCS: How to print unsigned long long (uint64_t ) using System_printf() and System_flush()
June 1, 2018 - Bits64 total_rx_bytes = 0; Bits64 total_tx_bytes = 0; char summary_text[128]; snprintf (summary_text, sizeof (summary_text), "tcpWorker stop clientfd=0x%x errno=%d total_rx_bytes=%llu total_tx_bytes=%llu\n", clientfd, fdError (), total_rx_bytes, total_tx_bytes); System_printf("%s", summary_text); System_flush ();