I have a question about getting a Bitmap from a character, for example A.
I was already searching in the internet but no direct help. I found this page, where my plans are described.
Quotation from this site:
e.g. character char=”A” bits=”227873781661662″ which translates to “0000 0000 0000 0000 1100 1111 0011 1111 1111 1111 1100 1111 0011 1111 1101 1110” in binary.
How do they get from 227873781661662 to 0000 0000 0000 0000 1100 1111 0011 1111 1111 1111 1100 1111 0011 1111 1101 1110?
int num = 227873781661662;
int n = log(num)/log(2)+1; //Figure out the maximum power of 2 needed
NSString *result = @""; //Empty string
for (int j=n; j>=0; j--) //Iterate down through the powers of 2
{
if (pow(2,j) >= num) //If the number is greater than current power of 2
{
num -= pow(2,j); //Subtract the power of 2
result = [result stringByAppendingString:@"1"]; //Add a 1 to result string
}
else result = [result stringByAppendingString:@"0"]; //Otherwise add a 0
if (num == 0) break; //If we're at 0, stop
}
NSLog(@"num = %i",num);
What is wrong with this? Thanks for help
To convert a number from decimal to binary:
With the example

numabove output is: