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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:30:08+00:00 2026-06-14T08:30:08+00:00

Consider the below code. int value1 = BOOST_BINARY( 100 111000 01 1 110 );

  • 0

Consider the below code.

int value1 = BOOST_BINARY( 100 111000 01 1 110 );

Can somebody explain how BOOST_BINARY calculates the int value there?

  • 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-14T08:30:09+00:00Added an answer on June 14, 2026 at 8:30 am

    It is very, very complicated. This BOOST library uses macros constructed by others macros.

    I am going to present you some simplified example of preprocessor programming:

    The simplified question:

    How to make macro adding 0 or 1 at the beginning of rest – like in this examples:

    CAT ( 0 1 ) --> 01
    CAT ( 1 100 ) --> 1100
    

    So – somehow , must be put between them both arguments in sequence. Well I did this:

    // start point - this is our desired format
    #define CATS(a,b) a##b
    // helper macro to invoke preprocessor on result of a
    #define CALLP(a) a
    // some helper symbols to build CATS() 
    #define CATB (
    #define CATE )
    #define CATSN CATS
    //  I use that only 0 or 1 is expected at the beginning:
    //  CATS ( 0, 
    #define CAT_B0 CATSN CATB 0,
    //  CATS ( 1, 
    #define CAT_B1 CATSN CATB 1,
    
    // the final macro:
    // Example:
    //  CAT(0 XXX) --> CALLP( CAT_B ## 0 XXX  ) )  
    // --> CALLP(CAT_B0 XXX ) --> CALLP(CATSN ( 0, XXX ) )
    // --> CALLP( CATS(0, XXX) ) --> CATS(0,XXX) --> 0##XXX -> 0XXX 
    #define CAT(tt)   CALLP (CAT_B ## tt CATE)
    

    It really works (at least at gcc): http://ideone.com/EKlTGt

    Now imagine how complicated is work done by BOOST folks in their library? Yes, it is very complicated – but use such preprocessor tricks I presented, and maybe many others – I looked at the source of this BOOST library http://www.boost.org/doc/libs/1_46_1/boost/utility/binary.hpp today for the first time (believe or not).

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

Sidebar

Related Questions

Consider the below code fragment: double * p = new double[16]; int value =
Consider the Java code below, what would happen if there were no paintComponent method
Consider the sample code below : File1.cpp #include <iostream> static int x = 6;
Consider below functions f(int a[]) { ///CODE for for if(a[i] > 0) //change i
consider the code below: #include list.h struct List { int size; int* data; };
Consider the code below. What is going on there? #include <iostream> #include <stdio.h> using
Consider the really simple code below: #include <stdio.h> #include <stdlib.h> int main() { int*
Consider my C++ code below: int _tmain(int argc, _TCHAR* argv[]) { int by =
Consider the below code snippet: #include <stdio.h> int main() { int p = malloc(
Consider the C++ code below: bool a = 5; bool b = 6; int

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.