Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deciphering Bit-fields

Status
Not open for further replies.

scapps

Programmer
Jun 24, 2009
2
US
Greetings,

I am processing data which has what they call a "bit-field" with a range of 0x0000 to 0x7F83. I am using Fortran to read it in as an integer (16-bit). I need to look at each of the bit flag dependencies:

bit 9 - Is it a 0 or 1
bit 0 - Is it a 0 or 1
bit 1 - Is it a 0 or 1
bit 7 - Is it a 0 or 1
bit 8 - Is it a 0 or 1
bit 10 - Is it a 0 or 1
bit 11 - Is it a 0 or 1

How do I do this in Fortran90? Do I have to convert it from integer to something? I am lost. Any help would be appreciated.

Thanks.
 
You have to use IAND, IOR, IEOR functions.

Depends whether you number your bits from left to right or right to left. Say you have a 32 bit word. Is decimal 4 equal to bit 2 or bit 29?
 
Thanks. I figured it out. I will use the BTEST function. Seems to work fine.

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top