DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: #define and Hex Numbers

  1. #1
    john_trivolta Guest

    #define and Hex Numbers


    Just opened fcntl.h file and surprised to see the following # defines.

    #define _O_RDONLY 0x0000 /* open for reading only */
    #define _O_WRONLY 0x0001 /* open for writing only */
    #define _O_RDWR 0x0002 /* open for reading and writing */
    #define _O_APPEND 0x0008 /* writes done at eof */
    #define _O_CREAT 0x0100 /* create and open file */
    #define _O_TRUNC 0x0200 /* open and truncate */

    etc.

    I'm wondering, why do they use these hex numbers? I've seen many files where
    people do use 0x0000,0x0001, 0x0002, 0x0008 numbers. Is there someting special
    to use these HEX Numbers.

  2. #2
    marilyn Guest

    Re: #define and Hex Numbers

    They're less cumbersome than writing them in binary, and easier to see
    how they can be bitwise manipulated in binary or hex rather than written in
    base 10.


    "john_trivolta" <john_trivolta@planetaccess.com> wrote in message
    news:3d07c779$1@10.1.10.29...
    >
    > Just opened fcntl.h file and surprised to see the following # defines.
    >
    > #define _O_RDONLY 0x0000 /* open for reading only */
    > #define _O_WRONLY 0x0001 /* open for writing only */
    > #define _O_RDWR 0x0002 /* open for reading and writing */
    > #define _O_APPEND 0x0008 /* writes done at eof */
    > #define _O_CREAT 0x0100 /* create and open file */
    > #define _O_TRUNC 0x0200 /* open and truncate */
    >
    > etc.
    >
    > I'm wondering, why do they use these hex numbers? I've seen many files

    where
    > people do use 0x0000,0x0001, 0x0002, 0x0008 numbers. Is there someting

    special
    > to use these HEX Numbers.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center