For some base. Base 1 even. Some sort of complex substitution -ing.
Also, and of course, doing this is not a good idea in real life production code. I just asked out of curiosity.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You can relatively easy write macro which adds two integers in binary. For example – macro which sums two 4-bit integers in binary :
This macro can be easily extended for addition of two 8-bit or 16-bit or even 32-bit ints.
So basically all that we need is token concatenation and substitution rules to achieve amazing results with macros.
EDIT:
I have changed formating of results and more importantly – I’ve added overflow check.
HTH!