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 7189939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:24:31+00:00 2026-05-28T19:24:31+00:00

I’m looking at the source code of a C++ project similar to one that

  • 0

I’m looking at the source code of a C++ project similar to one that I am doing in Javascript for reference.

In C++, I have

#define FIRST_THING 0x0001
#define SECOND_THING 0x0002
...

What do these values mean? And how would I define this in Javascript? Things break if I try to just use 0x0001 and such, so could I just do

var FIRST_THING = 1
var SECOND_THING = 2

or is that completely different?

  • 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-05-28T19:24:33+00:00Added an answer on May 28, 2026 at 7:24 pm

    0x0001 is an integral constant in base 16, i.e., hexadecimal. It is still 1 in base 10. So yes, your example is equivalent, but do you know how to mentally parse 0xBC? If not then you need to study up on arbitrary base arithmetic or at least get comfortable with hex as any programmer should know this stuff.

    Sometimes it is easier to view numbers in hex form as they represent bit patterns. In hex, two digits correspond to a byte, so you know at a glance that 0xFF is 255 base 10 and 11111111 base 2. Work on some lower level projects for a while and it will become second nature.

    In your C++ example the integral constants are textually replaced by the preprocessor (i.e., all occurrences of FIRST_THING are replaced by 0x0001 before the code is compiled), you don’t have such a tool in javascript, so just assign the values to variables directly.

    You cannot create ‘constants’ in javascript, so it’s up to you to make sure that you don’t change them. However, you can simply write

    firstThing = 0x0001;
    

    And it will work just as the C++ example does, i.e., firstThing takes on the value of 1.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.