Bit mask in C

What is the best way to construct a bit mask in C with m set bits preceded by k unset bits, and followed by n unset bits:

00..0 11..1 00..0
  k     m     n

For example, k=1, m=4, n=3 would result in the bit mask:

01111000

Answers


~(~0 << m) << n


Need Your Help

if element width is greater than, then execute jQuery code

javascript jquery width element dynamic-css

I have the following javascript right below the relevant html area and it is not seem to be working. I'm pretty sure I have the correct method of getting the width of the relevant div tag but not s...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.