home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / ISBITON.PRG < prev    next >
Text File  |  1991-08-16  |  2KB  |  71 lines

  1. /*
  2.  * File......: ISBITON.PRG
  3.  * Author....: Ted Means
  4.  * Date......: $Date:   15 Aug 1991 23:02:26  $
  5.  * Revision..: $Revision:   1.3  $
  6.  * Log file..: $Logfile:   E:/nanfor/src/isbiton.prv  $
  7.  * 
  8.  * This function is an original work by Ted Means and is placed in the
  9.  * public domain.
  10.  *
  11.  * Modification history:
  12.  * ---------------------
  13.  *
  14.  * $Log:   E:/nanfor/src/isbiton.prv  $
  15.  * 
  16.  *    Rev 1.3   15 Aug 1991 23:02:26   GLENN
  17.  * Forest Belt proofread/edited/cleaned up doc
  18.  * 
  19.  *    Rev 1.2   17 Jul 1991 22:15:12   GLENN
  20.  * Ted sent a minor bug fix
  21.  * 
  22.  *    Rev 1.1   14 Jun 1991 19:52:04   GLENN
  23.  * Minor edit to file header
  24.  * 
  25.  *    Rev 1.0   01 Apr 1991 01:01:34   GLENN
  26.  * Nanforum Toolkit
  27.  *
  28.  */
  29.  
  30.  
  31. /*  $DOC$
  32.  *  $FUNCNAME$
  33.  *     FT_ISBITON()
  34.  *  $CATEGORY$
  35.  *     String
  36.  *  $ONELINER$
  37.  *     Determine the state of individual bits in a number
  38.  *  $SYNTAX$
  39.  *     FT_ISBITON( <nNumber>, <nBit> ) -> lResult
  40.  *  $ARGUMENTS$
  41.  *     <nNumber> is an integer for which a bit state needs to be checked.
  42.  *
  43.  *     <nBit> is a number from 0 to 15 that indicates which bit to test.
  44.  *  $RETURNS$
  45.  *     .T. if the specified bit was on., .F. if off.
  46.  *  $DESCRIPTION$
  47.  *     This function is useful when dealing with binary integers.  It will
  48.  *     come in very handy if you use the FT_INT86() function, because the
  49.  *     CPU flags are returned as a series of bits.  Using this function, you
  50.  *     can determine the state of each CPU flag.
  51.  *  $EXAMPLES$
  52.  *     if FT_ISBITON( nCPUFlags, 0 )
  53.  *        Qout( "The carry flag was set." )
  54.  *     endif
  55.  *
  56.  *     if FT_ISBITON( nCPUFlags, 7 )
  57.  *        Qout( "The sign flag was set." )
  58.  *     endif
  59.  *  $END$
  60.  */
  61.  
  62.  
  63. function FT_ISBITON( nWord, nBit )
  64.  
  65.   nWord := iif(nWord < 0, nWord + 65536, nWord)
  66.   nWord := int(nWord * (2 ^ (15 - nBit)))
  67.   nWord := int(nWord % 65536)
  68.   nWord := int(nWord / 32768)
  69.  
  70.   return (nWord == 1)
  71.