OiO.lk Blog C# Printing a negative _BitInt in C23
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

Exit mobile version