I have a character A. I converted this into a binary form(say B). I need to perform some operations using B. While doing this I need to check whether the element B(1)=1 or 0.
For doing so, I write
But it doesn't work. It works when I written like this-
What is the reason? Please tell me...
No products are associated with this question.
You are comparing the char '1' with the numeric 1.
>> double('1') ans = 49
as in the ASCII table.
You have to rescale '1' to 1:
'1'-'0' == 1
and in your case
B(1)-'0' == 1
Play games and win prizes!Learn more