tguclu <tugrul.guclu@gmail.comwrites:
Quote:
On Jul 26, 12:54 am, pete <pfil...@mindspring.comwrote:
Quote:
>tguclu wrote:
>>
Quote:
Is it possible to initialize an integer in binary form ? For example
like this?
>>
Quote:
int CrcHesapla()
{
int reg = 0x00;
int msg = b'1101011011';
}
>>
>Learn Hex!
>>
>b '11 0101 1011';
>0x 3 5 b
>>
>int msg = 0x35b;
Quote:
thx..i will note it down..
what about if you have lots of binary numbers with varying bit
numbers in a text file ?
Will you align them in nibles or woudly you prefer to do some trick
?
<OT>If the conversion was a one-off, I would use Perl. No more than
one line of code if the input file is relatively clean.</OT>
If you need to get the values into your program *at runtime* use the
library function strtoul -- it can convert using base 2.
Similarly, a few lines of standard C is all you'd need to write a
converter to turn the file of numbers in base two[1] to hexadecimal.
[1] I say 'in base two' because a 'file of binary numbers' is
ambiguous. The input seems to be a text file with numbers in base
two.
--
Ben.