"Fossies" - the Fresh Open Source Software Archive

Member "ccmath-2.2.1/manual/C14-util" (26 Sep 2000, 5772 Bytes) of package /linux/misc/old/ccmath-2.2.1.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1                               Chapter 14
    2 
    3                               UTILITIES
    4 
    5                                Summary
    6 
    7                The utility operation functions support access to
    8                individual bits in variables, and the display of
    9                bit patterns for each of the standard C data
   10                types.  An efficient integer power function,
   11                based on bit access, is included.
   12 
   13 -------------------------------------------------------------------------------
   14 
   15  Notes on Contents
   16 
   17      The utility functions implement some useful capabilities involving bit
   18  operations on binary data.
   19 
   20     bit  -------- set (bset), test (bget), and count (bcnt) the
   21                   bits in a (16-bit) word.
   22     lbit  ------- set (lbset), test (lbget), and count (lbcnt) the
   23                   bits in a (32-bit) long word.
   24     bpat  ------- display the bit pattern of a byte (bitpc 8-bits),
   25                   word (bitpn 16-bits), long word (bitpl 32-bits),
   26                   or double (bitpd 64-bits).
   27     bpatx  ------ display the bit pattern of an extended precision
   28                   number used in the extended precision segment of the
   29                   Numerical Analysis Library.
   30     pwr  -------- efficiently compute an integer power of a double
   31                   precision number.
   32 
   33 
   34 -------------------------------------------------------------------------------
   35 
   36  General Technical Comments
   37 
   38      The utility functions assume two's complement integers.  This is
   39  currently valid for most UNIX work stations and personal computers.  Bit
   40  display functions are often useful in the diagnosis of floating point
   41  arithmetic anomalies. They may be used in conjunction with the extended
   42  precision arithmetic of the CCM library to investigate the impact of
   43  truncated precision arithmetic on computations. IEEE 754 floating point
   44  formats used by a standard floating point processor and emulation software
   45  is assumed for the PC version of this library.
   46 
   47 -------------------------------------------------------------------------------
   48                            FUNCTION SYNOPSES
   49 -------------------------------------------------------------------------------
   50 
   51      Operate on Bits:
   52 -------------------------------------------------------------------------------
   53 
   54 bit and lbit
   55 
   56      Set, test, and count bits in a specified word (long word).
   57 
   58 bset
   59 
   60      unsigned short bset(unsigned short x,unsigned short n)
   61        x = input word
   62        n = bit to be set (rightmost = 0)
   63       return value: x' = word with bit n set
   64 
   65      -----------------------------------------------------------
   66 
   67 lbset
   68 
   69      unsigned int lbset(unsigned int x,int n)
   70        x = input long word
   71        n = bit to be tested (rightmost = 0)
   72       return value: x' = long word with bit n set
   73 
   74      ----------------------------------------------------------
   75 
   76 bget
   77 
   78      int bget(unsigned short x,unsigned short n)
   79        x = input word
   80        n = bit to be tested (rightmost = 0)
   81       return value: f = test flag, with
   82                         0 -> bit n not set (=0)
   83                         1 -> bit n set (=1)
   84 
   85      -----------------------------------------------------------
   86 
   87 lbget
   88 
   89      int lbget(unsigned int x,int n)
   90        x = input long word
   91        n = bit to be tested (rightmost = 0)
   92       return value: f = test flag, with
   93                         0 > bit n not set (=0)
   94                         1 > bit n set (=1)
   95 
   96      -----------------------------------------------------
   97 
   98 bcnt
   99 
  100      int bcnt(unsigned short x)
  101        x = input word
  102       return value: m = count of bits set in x
  103 
  104      ------------------------------------------------
  105 
  106 lbcnt
  107 
  108      int lbcnt(unsigned int x)
  109        x = input long word
  110       return value: m = count of bits set in x
  111 
  112 
  113 -------------------------------------------------------------------------------
  114 
  115      Display Bits of Operand:
  116 -------------------------------------------------------------------------------
  117 
  118      Print the bit pattern of the operand, starting at the current cursor
  119      location.
  120 
  121 bitpc
  122 
  123      void bitpc(unsigned char x)
  124        x = input character (length= one byte)
  125 
  126      ------------------------------------------------
  127 
  128 bitpn
  129 
  130      void bitpn(unsigned short x)
  131        x = input short integer (length= two bytes)
  132 
  133      -------------------------------------------------
  134 
  135 bitpl
  136 
  137      void bitpl(unsigned int x)
  138        x = input integer (length= four bytes)
  139 
  140      --------------------------------------------------
  141 
  142 bitpf
  143 
  144      void bitpf(float x)
  145        x = input float
  146             ( 1 sign bit, 8 exponent bits, 23 bit mantissa )
  147 
  148      --------------------------------------------------
  149 
  150 bitpd
  151 
  152      void bitpd(double x)
  153        x = input double
  154             ( 1 sign bit, 11 exponent bits, 52 bit mantissa )
  155 
  156      ---------------------------------------------------------------
  157 
  158           The exponent field in floats and doubles is separated from
  159           the mantissa by the '^' character.
  160 
  161 -------------------------------------------------------------------------------
  162 
  163      Extended Precision Patterns:
  164 -------------------------------------------------------------------------------
  165 
  166      The header file ccmath.h or xper.h must be included when this
  167      function is used.
  168 
  169 bpatx
  170 
  171      void bpatx(struct xpr x)
  172        x = structure containing extended precision real number
  173            ( 1 sign bit, 15 exponent bits, 112 bit mantissa )
  174 
  175 
  176 -------------------------------------------------------------------------------
  177 
  178      Integer Power Function:
  179 -------------------------------------------------------------------------------
  180 
  181 pwr
  182 
  183      Compute an integral power of a double precision number.
  184 
  185      double pwr(double y,int n)
  186        y = input number
  187        n = power desired
  188       return value: z = y^n