October 24, 2024
Chicago 12, Melborne City, USA
C#

Printing a negative _BitInt in C23


If I have the following code:

_BitInt(6) c = -20;
printf("Valore di _BitInt(6) c: %d\n", c); 

The printf gives as value 236 and not -20

I noticed that to print the correct value I should write the following code instead using the cast to int operator.

printf("Valore di _BitInt(6) c: %d\n", (int)c);

What is the explanation?

Maybe printf without (int)c makes a wrong conversion of c into an unsigned 8 bit int?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video