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 :7045
No related posts.
Tags: C Codes, fortran, Windows XP
This entry was posted on Friday, July 30th, 2010 at 1:25 am and is filed under C Language. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.