How can memory be improved?

How frequently you use bitwise operators and how much percentage of the time and/or memory complexity improved with these changes?

  • Answer:

    I assume you mean using bitwise operators as opposed to higher level logic.. Such as logical operators. It's always implementation specific. If you have a small amount of code that runs very frequently, or you need real-time performance, then you're often making whatever optimizations you can manage. Every microsecond counts in a loop run thousands of times per second. Often bitwise operations are equally simple or simpler than higher level equivalents, if things are designed to accommodate. For changing a letter's case, just flip the 5th bit, for instance. EnumSets in Java are backed by very efficient bitmaps. And if you learn about bit-indexed trees, you'll be amazed. Why add the first 15 elements to get a sum when you can add precalculated sums of the first 8, next 4, next 2, and then the 15th.. Microsoft Cube calculates numbers very fast this way, mapping the precalculated totals to each bit. But if it's something that runs.infrequently, and playing with bits is much less intuitive or even cumbersome, then don't think twice about it and just stick with high level operations.

Scott Danzig at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.