Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8233219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:03:43+00:00 2026-06-07T18:03:43+00:00

No matter which C-compatible library I use, when I look at the header defined

  • 0

No matter which C-compatible library I use, when I look at the header defined constants, they are always defined as hexadecimal values. Here, for instance, in GL/gl.h:

#define GL_POINTS                               0x0000
#define GL_LINES                                0x0001
#define GL_LINE_LOOP                            0x0002
#define GL_LINE_STRIP                           0x0003
#define GL_TRIANGLES                            0x0004
#define GL_TRIANGLE_STRIP                       0x0005
#define GL_TRIANGLE_FAN                         0x0006
#define GL_QUADS                                0x0007
#define GL_QUAD_STRIP                           0x0008
#define GL_POLYGON                              0x0009

Is there any particular reason for this convention, why not simply use decimal values instead?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:03:44+00:00Added an answer on June 7, 2026 at 6:03 pm

    There are a number of possible reasons:

    1) Bit flags are much easier to express as hex, since each hex digit represents exactly 4 bits.

    2) Even for values which aren’t explicitly bit flags, there are often intentional bit patterns that are more evident when written as hex.

    For instance, all the AlphaFunctions start with 0x02 and differ in only a single byte:

    #define GL_NEVER                          0x0200
    #define GL_LESS                           0x0201
    #define GL_EQUAL                          0x0202
    #define GL_LEQUAL                         0x0203
    #define GL_GREATER                        0x0204
    #define GL_NOTEQUAL                       0x0205
    #define GL_GEQUAL                         0x0206
    #define GL_ALWAYS                         0x0207
    

    3) Hex values are allowed to have leading zeroes, so it is easier to line up the values. This can make reading (and proof-reading) easier. You might be surprised that leading zeroes are allowed in hex and octal literals but not decimal, but the C++ spec says quite explicitly

    A decimal integer literal (base ten) begins with a digit other than 0 and consists of a sequence of decimal digits.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use curses.h library for the first time, but no matter which
Assume I've declared a function (or class, doesn't matter) in a header file, which
I have a master record which I'd like to use with. Here's a very
Does it actually matter which CDN you use to link to your jquery file
I continually get a logon error no matter which logon I use or from
i am trying to use a log viewer (doesn't matter which one) to parse
Possible Duplicate: JavaScript === vs == : Does it matter which “equal” operator I
I have a UIControl (or UIView, doesn't matter which) and this is covered by
Assume a master array which is already sorted in ASCENDING order: $values = array('value1',
Does it matter which way the following selector is written? It validates both ways

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.