Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • After spending about 10 minutes figuring out why it works, that kicks A**! Thanks! Commented Jul 21, 2009 at 2:18
  • @Charles Bailey, well it took me longer than 10 minutes since my template programming is pretty rusty and I have to agree that it is a very nice and elegant solution. The key is to realize that T(1) will be turned into a value of 1 for the type then the one is shifted so that it will be in the next nibble then subtract 1 to get the 0xf. So an example for unsigned short would be 0x0001 then shifted would be 0x0010 then subtract one to get to 0x000f. Commented Sep 10, 2012 at 2:56