Mahol Dot Org

Icon

Weblog For All Your Need

Emulate Fortran Function Btest In C Language

Emulate the fortran function btest in C language
BTEST function is as part of Bit Functions library in Fortran,
description of BTEST function

btest( m, i ) Tests bit i in m; returns .true. if the bit is 1, and .false. if it is 0.
Here is C language code implementation of BTEST function, which checks for bit and returns true ie 1 if bit is SET or else returns 0.

int btest(int word, int bit)
{
  unsigned int mask;

  /* Create the bit mask */
  mask = 0x0000001 << bit;

  /* Return TRUE or FALSE*/
  return (( word & mask ) != 0);
}
Number of View :879

No related posts.

Receive Updates By Email

Enter your email address:

Delivered by FeedBurner

Category: C Language

Tagged: , ,

Leave a Reply

Lost !! Use Advanced Search

Categories

Content Protected Using Blog Protector By: PcDrome.

Mahol Dot Org is Digg proof thanks to caching by WP Super Cache