General Discussions

Multiples of 8

To check if the number is multiple of 8, the bitwise way is that: first right shift by 3 and then left shift by 3. Multiple of 8 will remain the same as original number after this operation. Examples: 8:        1000 >> 3 :  0001 <<3  :  1000 24:      11000… Continue reading Multiples of 8

General Discussions

Check if all Bits Set

To check if all the bits are set for a given number, AND the given number n with n+1. If all the bits are set, then the result will be 0. Examples: n = 4          100 n+1 = 5      101 ———————– AND result         100 n =… Continue reading Check if all Bits Set

General Discussions

Union-Find Data Structure: Intro

Originally posted on PH Bytes:
A disjoint-set data structure, also called a union–find data structure keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets. With this setting we define the following operations: Find: Determine which subset a particular element is in. This can be used for determining if two…

General Discussions

Checking Alternate Bits Set

To check if alternate bits are set, Carry out the following operations: First XOR the number n and (n >> 1). If alternate bits are set then this will produce all 1’s. Let us call the result as m To check is all the bits are set to 1, AND m with m + 1… Continue reading Checking Alternate Bits Set

General Discussions

XOR and Binary Addition

Consider the following: and, As we can clearly see, XOR simulates binary addition without the carry over to the next digit.

General Discussions

Fibonacci Versions – C

Originally posted on PH Bytes:
This post covers the three implementation(Iterative, Recursive and Dynamic) version of Fibonacci series. The correctness of the code covers for integer range numbers only. 1. Iterative Version #include int fibo(int n) { int previous = 1; int current = 1; int next = 1; int i; for (i = 3;…

General Discussions

100000 Hits

Originally posted on Its PH:
Those numbers sure call for a ‘Happy Dance’. The blogging journey began on 16 July 2014 with the post Is this Life All About? – A New Old. The blog today has 488 posts, 101 pages, 12,501 comments and 3434 followers. Thank you, you kind fellow bloggers and friends. 100000 hits…

General Discussions

Software Karma

Originally posted on PH Bytes:
“Exploring Completeness in the Incompleteness” We would never buy a car if it has the engine missing or another part per say. Even if the manufacturer promised us to deliver by next six months, we would feel crazy and would not agree to it.  We would never purchase anything which…

Ebooks

Production and Consumption – Market

The market is driven by producers and consumers based on the demand and supply. There is a demand from a consumer and those demands are fulfilled by the producers and so how the ends meet. However, market is about finding that right balance between that production and consumption (that need not be essentially called so).… Continue reading Production and Consumption – Market