Can the intmax_t hold size_t?

756 Views Asked by At

Can the intmax_t hold size_t maximum decimal number? And what size type in printf have a biggest priority uintmax_t/intmax_t or size_t (ex. if i write printf("%zjd", x))?

2

There are 2 best solutions below

0
Clearer On BEST ANSWER

Most likely not

Both are implementation specific, so it's not really possible to answer.

size_t is (usually) an unsigned integer holding the largest possible number of bits that will fit in a register on a given CPU. That's not exactly guaranteed in reality though, but I still haven't found an example where this isn't true.

intmax_t is a signed integer, meaning it will probably have the bits required to store any value that a size_t can hold, but large values will not mean the same; the largest value that a size_t can hold, is likely going to be a negative integer when interpreted as an intmax_t.

2
unwind On
  1. No, since size_t is unsigned that risks dropping one bit.
  2. I don't think you understand how printf() works, you can have "an optional length modifier" but not more than one.