1. To convert binary
2. The binary invert
3. After the not add 1 at the end of.
4. Determine whether it is negative, such as the D2 (decimal 210) converted to decimal, then determine the if (210 & gt; 127) than is positive, whereas negative
Is a binary number in the char data, then a comparison of a, is this kind of treatment?
CodePudding user response:
Turns into a binary number to a decimal number, are going to have to read every binary numberCodePudding user response:
Fyi:# include & lt; Stdio. H>
#include
#include
#include
Int main () {
Int I, v;
Char bs [33].
Char b [33];
Char hs [9].
Char h [9];
Char s [4];
Char * e;
//decimal integer binary string;
I=1024;
Ltoa (I, b, 2);
Sprintf (bs, "% 032 s", b);
Printf (" I=% d, bs=% s \ n ", I, bs);
//decimal integer hexadecimal string;
I=1024;
Ltoa (I, h, 16);
Sprintf (hs, "% s" 08, h);
Printf (" I=% d, hs=% s \ n ", I, hs);
//hex string converted to a decimal number
Strcpy (hs, "00000400");
Sscanf (hs, "% x", & amp; I);
Printf (" the hs=% s, I=% d \ n ", the hs, I);
//binary string into hexadecimal string;
Strcpy (bs, "00000000000000000000010000000000");
I=strtol (bs, & amp; E, 2);
Ltoa (I, h, 16);
Sprintf (hs, "% s" 08, h);
Printf (" bs=% s, hs=% s \ n ", bs, hs);
//binary string converted to a decimal number;
Strcpy (bs, "00000000000000000000010000000000");
I=strtol (bs, & amp; E, 2);
Printf (" bs=% s, I=% d \ n ", bs, I);
//hex string into a binary string
Strcpy (hs, "00000400");
Sscanf (hs, "% x", & amp; I);
Ltoa (I, b, 2);
Sprintf (bs, "% 032 s", b);
Printf (" the hs=% s, bs=% s \ n ", hs, bs);
//ASC \ GBK string hexadecimal string
Strcpy (s, "a han");
I=0;
While (1) {
If (0==s [I]) break;
Sprintf (hs + I * 2, 02 x %, (unsigned char) s [I]);
i++;
}
The setlocale (LC_ALL, "CHS");
Printf (" s=% s, hs=% s \ n ", s, hs);
//hex string into (GBK Chinese characters) and characters (ASC)
Strcpy (hs, "61 baba");
I=0;
While (1) {
If (1!=sscanf (hs + I * 2, "% 2 x", & amp; V)) break;
S [I]=(char) v.
i++;
}
S [I]=0;
Printf (" the hs=% s, s=% s \ n ", hs, s);
return 0;
}
//I=1024, bs=00000000000000000000010000000000
//I=1024, hs=00000400
//hs=00000400, I=1024
//bs=00000000000000000000010000000000, hs=00000400
//bs=00000000000000000000010000000000, I=1024
//hs=00000400, bs=00000000000000000000010000000000
//s=a han, hs=61 baba
//hs=61 baba, s=a han
CodePudding user response:
Whatever the hexadecimal, number or the number of methods are thoseD2 if access is in the form of a string to
It is directly related operations can be converted to int
CodePudding user response: