in reply to how to pack bits, flags and masks
You're making this too difficult. The dword is a 32-bit native integer -
All you need to test or set bits are the bitwise operators &, |, and ^, and their assignment forms, &=, |=, and ^=.perl -e'print 0x00500000,$/ 5242880 $
For example, to test if bit 7 is set in $value,
The bit manipulations you show should work fine on your data as it is.if ($value & 1<<6) { #do something }
Even if you read your number as a decimal string, it should automatically be converted to an unsigned numeric type by the bitwise operators.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to pack bits, flags and masks
by anadem (Scribe) on Nov 15, 2004 at 19:18 UTC | |
by ikegami (Patriarch) on Nov 15, 2004 at 19:51 UTC |