Question #6713   Submitted by Answiki on 09/23/2022 at 11:47:00 AM UTC

In C, how to convert an integer to binary?

Answer   Submitted by Answiki on 09/23/2022 at 11:48:50 AM UTC

There is no standard function in C to convert or display an integer in its binary form. However, some libraries (quite rare) implement the %b format code which allows to display an integer in binary form:

// Display 100 on some environments
printf ("%b", 4);

If you need to convert an integer to binary, then you will have to write a dedicated function. Depending on your needs, select one of the following options:


2 events in history
Answer by Answiki on 09/23/2022 at 11:48:50 AM

There is no standard function in C to convert or display an integer in its binary form. However, some libraries (quite rare) implement the %b format code which allows to display an integer in binary form:

// Display 100 on some environments
printf ("%b", 4);

If you need to convert an integer to binary, then you will have to write a dedicated function. Depending on your needs, select one of the following options:


Question by Answiki 09/23/2022 at 11:47:00 AM
In C, how to convert an integer to binary?
# ID Query URL Count

Icons proudly provided by Friconix.