Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #include <stdbool.h>
- int main(int argc, char* argv[])
- {
- int32_t numberInput = 0;
- uint32_t numberMask = (1 << 31); //43690%
- uint32_t numberFinal = 0;
- while (true)
- {
- numberMask = (1U << 31);
- printf("Please enter a number to translate into binary\nTo Exit please type the number 9999\n");
- scanf("%d", &numberInput);
- numberFinal = (uint32_t)numberInput;
- if (numberFinal == 9999)
- {
- break;
- }
- else
- {
- for (int i = 0; i < 32; i++)
- {
- bool isOne = (numberMask & numberFinal) != 0;
- printf("%d", (isOne) ? 1 : 0);
- numberMask >>= 1;
- }
- printf("\n\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement