# convert « binary « C Data Type Q&A

Home
C Data Type Q&A
 1 binary 2 bit 3 byte 4 char 5 character 6 decimal 7 Development 8 float 9 hex 10 integer 11 prime 12 random 13 struct
 C Data Type Q&A » binary » convert

### 2. Converting hexadecimal to binary    bytes.com

Converting hexadecimal to binary is really quite simple: Just convert each hexadecimal character to its four digit binary equivalent. so 0xff = 1111 1111 or 0x27b=0010 0111 1011 //I have left spaces so that it easier to read so write the code that will accomplish this and half the problem is solved

### 3. Optimization of Binary Converter    bytes.com

The characters in a string are already integers. That is, a char containing A is already in binary. Has to be. It's in the computer. In this case the A is 65 so all you need do is convert that 65 to binay. You convert the char directly to binary. (str[i] / n ) % 2 ) will get the bit ...

### 4. Two simple program conversion to Binary    bytes.com

Hi,, I have two questions as follows: write a C++ program to convert an unsigned integer number to Binary. wriet a C++ program to convert a Hexadecimal number to Binary. I heard that is very easy but I can not write so, please i want help from us as harry up as you can please. I don't know who harry is ...

### 5. Conversion from binary    bytes.com

Write a program to print out the integers from 40 to 127 in decimal, octal, hexadecimal and also print out the equivalent character. ************************************/ #include using namespace std; void main(){ for (int i(40); i <= 127; i++){ cout<<"Decimal Value:"<

### 6. binary conversion    bytes.com

Hi, I wish to compare 2 black and white images of about 4000 pixels. So I have 2 arrays of 4000 integers int of value 0 or 1. My idea was to convert each array to a single binary number built by putting all the integers one after the other. I could then convert this number to a base 10 number. ...

### 8. Converting to binary    bytes.com

Hi, as far as I am concern, itoa doesnt convert from decimal to binary. It converts from integer to string(ascii, thats why i(integer) to a(ascii)). For example, if you have an integer 1225, then itoa will convert it into "1225". You will be better of writing your own code for decimal to binary conversion:) Did you really meant to convert from ...

### 15. Convert 10.2 to binary    cboard.cprogramming.com

#include void dec_bin(int number); int main(void) { int input = 0; printf("Digit (0-255): "); scanf("%d", &input); (input >= 0) && (input < 256) ? dec_bin(input) : exit(1); return 0; } void dec_bin(int number) { int x, y; x = y = 0; for(y = 7; y >= 0; y--) { x = number / (1 << y); number = number ...

### 18. convert word to binary    cboard.cprogramming.com

Not again!!! Heres my code; its my first real C-program: Code: #include #include #define PUFFER 256 void asctobin(void); /* converts ASCII-characters into binary digits */ void bintoasc(void); /* converts binary digits into ASCII characters */ unsigned char bin[]={1,2,4,8,16,32,64,128}; int main(void) { char chose; for(chose=0;chose<40;chose++,printf("\n")) ; /* clear screen */ again: printf("Enter \'A\' to convert ASCII to binary or \'B\' ...

### 19. Gray Code to Binary Code Conversion!    forums.devshed.com

Smile Gray Code to Binary Code Conversion! Hi guys, So I'm trying to write a function that will convert a 7-bit Gray code to the corresponding 7-bit Binary Code. Here's how to convert - * Gray Value bits ---- MS bit > (G6) G5 G4 G3 G2 G1 G0 * * Binary Value bits -- MS bit > (B6) B5 B4 ...

### 20. Binary Converter    forums.devshed.com

Pay attention to Lux, but I think you MIGHT have a basic problem. All information that your computer deals with is binary. Any given pattern of bits might be interpreted as a numerical value according to things like twos-complement, ones-complement, IEEE-754, and the like. It might also be interpreted as ASCII/ANSI, EBCDIC, or any number of other things which decide to ...

### 21. Binary Converter    forums.devshed.com

Hi all. As you may probably know, I'm new here. I joined this forum because I've started doing some basic C programming. Here is a source file I wrote to convert Binary numbers to decimals. Your help will be greatly appreciated! The thing is, it prints something like 2293600 each time. There is no error either. I dunno why. Please help ...

### 22. Binary conversion problem    forums.devshed.com

One of the first dictums in the "New users - HOW TO POST A QUESTION - READ THIS FIRST" thread is SEARCH FIRST. If you look at the list of topics for this forum you will find the subject mentioned within a half-dozen threads of yours. Have you read that "New users" thread? If not, why not?

### 23. Denary to Binary conversion    forums.devshed.com

Howdy all. I'm trying to write a program to take a denary (base 10) number and convert it to binary, in C. I've got my code (as follows), and all the compilation errors are finally out (curse those extra brackets), but the program's not working. I *think* it's getting caught in an infinite loop after the denary number has been entered, ...

### 24. Converting Binary to any base and any base to Binary    forums.devshed.com

I am new to C. I want to design a calculator which converts a number of any base to a specified base. I have already done in any other base except Bianary (base 2). Is there any one who can tell me how to make a C function to convert a binary number to any base or any base to binary ...

### 25. Convert hexa to binary    forums.devshed.com

#define EN0 0 /* MODE == encrypt */ #define DE1 1 /* MODE == decrypt */ typedef struct { unsigned long ek[32]; unsigned long dk[32]; } des_ctx; extern void deskey(unsigned char*, short); /* hexkey[8] MODE * Sets the internal key register according to the hexadecimal * key contained in the 8 bytes of hexkey, according to the DES, * for encryption ...

### 26. need programe convert from binary to dicimal    forums.devshed.com

Before leaving, I ll give you something... A good way to solving this problem is creating a string object called std::string str then declare an iterator runing thru thru each char, taking the position of each 1 and assign them in an array, Okay ? you dont have to use mem allocation, it s gonna be more complex since your problem ...

### 27. Problem converting from writes to txt db to binary db    forums.devshed.com

If you have a moment, could you please look at the attached code? I am trying to convert the working code from reading/writing to a text database to a binary one.I thought that all I needed to do was change the file write operation from a fprintf to a fwrite but something is off. When I compile the formerly working code, ...

### 35. Binary conversion    tek-tips.com

#include #include #include using namespace std; template std::string ToBinaryString( T num ) { char c; const int size = (sizeof( T ) * 8); unsigned int mask = (1 << (size - 1)); std::stringstream str; ...