In C, how to write a function that displays an integer in binary?
The following C function displays an integer in binary:
// Convert and display an integer to binary
void int2bin(unsigned integer, int n=8) {
for (int i=0;i<n;i++)
putchar ( (integer & (int)1<<(n-i-1)) ? '1' : '0' );
}
Try online on repl.it.
See also:
The following C function displays an integer in binary:
// Convert and display an integer to binary
void int2bin(unsigned integer, int n=8) {
for (int i=0;i<n;i++)
putchar ( (integer & (int)1<<(n-i-1)) ? '1' : '0' );
}
Try online on repl.it.
See also:
The following C function displays an integer in binary:
// Convert and display an integer to binary
void int2bin(unsigned integer, int n=8) {
for (int i=0;i<n;i++)
putchar ( (integer & (int)1<<(n-i-1)) ? '1' : '0' );
}
Try online on repl.it.
See also:
The following C function displays an integer in binary:
// Convert and display an integer to binary
void int2bin(unsigned integer, int n=8) {
for (int i=0;i<n;i++)
putchar ( (integer & (int)1<<(n-i-1)) ? '1' : '0' );
}
Try online on repl.it.
See also:
The following C function displays an integer in binary:
// Convert and display an integer to binary
void int2bin(unsigned integer, int n=8) {
for (int i=0;i<n;i++)
putchar ( (integer & (int)1<<(n-i-1)) ? '1' : '0' );
}
Try online on repl.it.
See also:
The following C function displays an integer in binary:
// Convert and display an integer to binary
void int2bin(unsigned integer, int n=8) {
for (int i=0;i<n;i++)
putchar ( (integer & (int)1<<(n-i-1)) ? '1' : '0' );
}
Try online on repl.it.
See also:
- En C, comment convertir un entier en binaire ?
- In C, how do you write a function that converts an integer to binary (into another integer)?
- In C, how do you write a function that converts an integer to binary in a string?
- Avec l'environnement Arduino, comment afficher un entier en binaire ?
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 13682 | alphons | https://en.ans.wiki/6709/in-c-how-to-write-a-function-that-displays-an-integer-in-binary | 1 |
| 1 | 11991 | en | https://en.ans.wiki/6709/in-c-how-to-write-a-function-that-displays-an-integer-in-binary | 13 |