From: John Ackermann N8UR (enigo@hospser.gr)
Date: Sun Mar 16 2003 - 00:54:18 EET
Thanks, Hamish. I don't know why it didn't work when I tried something
similar to that before. I'll give it another go.
73,
John
--On Sunday, March 16, 2003 09:46:04 +1100 Hamish Moffatt
<qckv.czjat@hayabusa.org> wrote:
> On Sat, Mar 15, 2003 at 02:24:47PM -0500, John Ackermann N8UR wrote:
>> I need to:
>>
>> (a) test whether one bit of a byte is set or not (e..g, is bit 5 of
>> $myvar a 1 or a 0);
>>
>> and
>>
>> (b) do a binary AND of two bytes (in other words, apply a bitmask).
>
> Binary AND is the "&" operator as in C. So
>
> $c = $a & $b;
> $y = $x & 0xFF;
>
> etc achieves (b), and similarly for (a),
>
> if ($myvar & 0x20) {
> ....
> }
>
> or perhaps more readably:
>
> if ($myvar & (1 << 5)) {
> ....
> }
>
>
> Hamish
> --
> Hamish Moffatt VK3SB <tfgmq@spectranet.com> <azn.cyupqiteo@sampo.fi>
>
>
-
To unsubscribe from this list: send the line "unsubscribe linux-hams" in
the body of a message to txtr.yialuqpd@tbwachiat.com
More majordomo info at http://vger.kernel.org/majordomo-info.html
This archive was generated by hypermail 2b30 : Sun Mar 16 2003 - 01:04:22 EET