How to use unsigned fixed-width integer type in C

2 Answers

0 votes
#include <stdio.h>
#include <inttypes.h>

int main(void)
{
    uint8_t ui8 = 255;
    uint16_t ui16 = 16000;
    uint32_t ui32 = 320000;
    uint64_t ui64 = 6400000;
    
    printf("%d\n", ui8);
    printf("%d\n", ui16);
    printf("%" PRId32 "\n", ui32);
    printf("%" PRId64 "\n", ui64);
}




/*
run:

255
16000
320000
6400000

*/

 



answered Apr 23, 2024 by avibootz
0 votes
#include <stdio.h>
#include <inttypes.h>

int main(void)
{
    uint_fast8_t ui8 = 255;
    uint_fast16_t ui16 = 16000;
    uint_fast32_t ui32 = 320000;
    uint_fast64_t ui64 = 6400000;
    
    printf("%d\n", ui8);
    printf("%ld\n", ui16);
    printf("%ld\n", ui32);
    printf("%" PRId64 "\n", ui64);
}




/*
run:

255
16000
320000
6400000

*/

 



answered Apr 23, 2024 by avibootz

Related questions

2 answers 205 views
1 answer 166 views
166 views asked Aug 24, 2017 by avibootz
1 answer 81 views
1 answer 119 views
1 answer 134 views
...