Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ bitvalue(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                             bitvalue(3C)



        _________________________________________________________________
        bitvalue                                        $builtin function
        Return the current value of a bit.
        _________________________________________________________________


        Calling Sequence

        #include <bit.h>
        int bitvalue();
        short *ptr;
        int offset, value;
        value = bitvalue(ptr, offset);

        or

        $builtin int bitvalue();
        short *ptr;
        int offset, value;
        value = bitvalue(ptr, offset);


        Description

        The bitvalue function returns the value of the bit specified by a
        word pointer, ptr, and a non-negative bit offset, offset.  Note
        that the most significant bit in the 16-bit word pointed to by
        ptr is at offset 0, and the least significant bit is at offset
        15.  If the offset is negative, the bitvalue routine may cause an
        error.

        The first calling sequence noted above uses a function call.  The
        second might generate smaller or faster code, but may not run
        under other C compilers.

        The include file bit.h defines this function.


        Returns

        The bitvalue function returns 0 or 1 depending on whether the bit
        addressed is 0 or 1.


        Related Functions

        See also the bitset and bitszbo functions.


        Example




        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                             bitvalue(3C)



        /* Program test for the bitvalue() function */

        #include <bit.h>
        #include <stdio.h>


        short s, bit15, bit0;

        main() {
            s = 3;                       /* bits 15 & 14 are 1 */
            bit0 = bitvalue(&s, 0);      /* value on bit 0 */
            bit15 = bitvalue(&s, 15);    /* value on bit 15 */

            (void) printf("s = %hx (hexadecimal)\n", s);
            (void) printf("bit0 = %d\n", bit0);
            (void) printf("bit15 = %d\n", bit15);
        }

        The above program produces the output

        s = 3 (hexadecimal)
        bit0 = 0;
        bit15 = 1;































        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026