C function: multiply 2 numbers using bit twiddling? [closed] - c

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I need some help answering the above question Any twiddling idea?

You'll get a lot more here: Bit Twiddling Hacks

Treat one of the inputs as a bitmask. For each bit in it that is set, you want to add the other input, shifted that many spaces left, to your result. This assumes unsigned inputs: non-2's-complement signed inputs require special treatment of the sign bit.
I think I can safely predict that this will be less efficient than the CPU's built-in multiply operation.

Related

How to deal with very large integers? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
If I have to store and do an operation on integers in the wide range of [1, 10^50000]. How can I do them? How can I store such large integers values first of all? And, how can I perform basic operations on them subsequently?
There are specialized libraries for arbitrary precision that will help you with this. One I had success with is GMP.

how to split a decimal integer into ascii values? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a 4 digit decimal number say 1234. I want to split this number into 4 separate ASCII values like '1','2','3','4'.
The process should not include division operation or integer to string conversion etc.
You want to extract each digit of the number and add '0'. If this is against your requirements, feel free to ignore.
you can anytime change division operator subtraction anytime.

Substitution of one type by another [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
When we perform substitution, can one type substitute another type?
This is too broad a question because it concerns general concepts of programming rather than specific programming language.
Thank You.
Substitution of one type for another is purely dependent on your requirement.
You can also typedef the given type or you can make your own type.
You can perform type substitution using template also
Btw your question is little incomplete to give accurate answer , what exactly you want to ask?

Why is C function so long? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm coming from a script guy, used to functions within 50 lines.
And when I see frequently functions over 200 lines,I'm really having a hard time reading it.
Is this normal at all?
There is nothing in the language that makes functions "long" - you can write long functions in any reasonable language, and, ideally, should refactor them into smaller, more understandable and maintainable functions in most languages.

how to build a calculator in GTK+? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
what's the logic behind the calculator widget. i want to build it in gtk+.
First, don't listen to anyone who says that this is trivial.
Second, I'm going to assume that you really mean something like "How do I convert the user input to an internal expression structure which I can use to calculate the answer?". Well, Wikipedia has a good article (here) on converting infix (human readable) notation, which is what most modern calculators use (e.g you can write 1 + 2 instead of + 1 2), to the more computer appropriate polish (prefix) notation.
Third, if you don't know GTK+ yet, start here.
Hope this helps.

Resources