Hi all,

 

This is my first email to this list; please point me out if I done anything wrong in this mail like the title format or etc…

 

I am a newbie to the Boost library. I am really interesting on the usage of the Boost preprocessor library. I would like to archive 1 of the thing but I am not sure whether it is possible with Boost preprocessor library:

            Converting the binary number to hexadecimal or decimal value

 

Eg: BIN2HEX(011) -> 0x3 or  BIN2DEC(011) -> 3

      BIN2HEX(1111) -> 0xf or  BIN2DEC(1111) -> 15

 

I had read the C-Template-Metaprogramming-Concepts-Tools-and-Techniques-from-Boost-and-Beyond-C-in-Depth-Series which tell me how to archive that using template. But what I really want is to done it with the preprocessor without using any template which will not affect the run time but only the compile time.

 

I know that I can use the loop and the arithmetic function from the Boost library but how do I get the binary number characters count, eg. COUNT(011) -> 3 or COUNT(0111) -> 4. So that I can use this count with loop and the arithmetic function to perform the conversion from binary to hexadecimal or decimal.

 

 

Thanks in advance.

Regards,
Shin Guey