Welcome,
%1$s
. Please
login
or
register
.
February 21, 2018, 05:12:44 PM
Submit
Quotes
CELL TRACKER
Online Fun Database

Interview Questions

C Questions

Macro to find check divisibility by 16
Random
Celebrities
Places
Humour
Quotes
Informative
Articles
Stories
Indian
Videos
Puzzles
Easy
Medium
Tough
On Maths and Physics
What am I?
Puzzled PJs
« previous
next »
:
1
: Macro to find check divisibility by 16 ( 3342 )
Macro to find check divisibility by 16
«
:
May 12, 2007, 12:31:43 AM From
Shrinidhi
»
Macro to find check divisibility by 16
Write a macro to find whether a number is divisible by 16 or not (without using Math library)
Liked It? Share it!
Tweet
Re: Macro to find check divisibility by 16
«
#1 :
May 18, 2007, 11:43:30 PM From
Prateek
»
#define isDivisibleBy16(x) !( x & 0xF )
A number is divisible by 2 if its least significant bit is 0.
A number is divisible by 4 if its least 2 significant bits are 0.
A number is divisible by 8 if its least 3 significant bits are 0.
A number is divisible by 16 if its least 4 significant bits are 0.
Re: Macro to find check divisibility by 16
«
#2 :
May 19, 2007, 12:08:27 AM From
Poonam
»
The above macro does not take care of zero condition.
i.e if x is 0 it still returns saying that the number is divisible by zero.
So slightly modifying it.
#define isDivisibleBy16(x) (!( x & 0xF ) && x)
Re: Macro to find check divisibility by 16
«
#3 :
May 19, 2007, 11:23:26 AM From
Ria
»
What if the number is negative?
:
1
« previous
next »
Best Rated
List All>>
Latest
Random
Loading...