Page 1 of 1
How to know the first bit of a data byte
Posted: Sun Jun 11, 2017 11:08 pm
by Brewling
When I receive an APDU command, I have to see the first bit of the first data byte,1 or 0.
Is there an easier way to see an specific bit from a byte in java card?
Thanks a lot for any help.
Re: How to know the first bit of a data byte
Posted: Mon Jun 12, 2017 4:01 am
by Tazmania09
You may try to use AND operation to know the bit value.
For example,
Make your data do the AND operation with 0x80.
So,
- if it is 1 in the first bit, the operation result will be 0x80.
- and if it is 0 in the first bit,the operation result will be 0.
Re: How to know the first bit of a data byte
Posted: Mon Jun 12, 2017 4:42 am
by Brewling
Wow, that a good idea. Thanks Tazmania09. You saved my day.
