Click here to Skip to main content
15,846,726 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: How to test equality Pin
Jaime Olivares31-Oct-09 20:20
Jaime Olivares31-Oct-09 20:20 
GeneralRe: How to test equality Pin
dojohansen8-Jan-10 0:16
dojohansen8-Jan-10 0:16 
JokeRe: How to test equality Pin
Jeroen De Dauw28-Oct-09 12:44
Jeroen De Dauw28-Oct-09 12:44 
GeneralRe: How to test equality Pin
Super Lloyd29-Oct-09 15:14
Super Lloyd29-Oct-09 15:14 
GeneralRe: How to test equality Pin
supercat930-Oct-09 10:26
supercat930-Oct-09 10:26 
GeneralRe: How to test equality Pin
Richard MacCutchan31-Oct-09 1:06
mveRichard MacCutchan31-Oct-09 1:06 
GeneralRe: How to test equality Pin
OriginalGriff31-Oct-09 1:51
mveOriginalGriff31-Oct-09 1:51 
GeneralRe: How to test equality Pin
supercat91-Nov-09 14:47
supercat91-Nov-09 14:47 
Richard MacCutchan wrote:
In my experience the more simple and standard the code is the better. Whether you write bitVar = !!(byteVar & 0x40); or bitVar = ((byteVar & 0x40) != 0);, chances are the compiler will optimise it and generate the same object code.


I use the more verbose syntax when testing more than one bit, to make explicit whether I am checking for any bit being set, or all bits being set. Whether or not anyone else uses the same convention, I find that at least in my own code it's nice to be able to distinguish at a glance between single-bit tests and multi-bit tests.
GeneralRe: How to test equality Pin
PJ Arends1-Nov-09 8:39
professionalPJ Arends1-Nov-09 8:39 
GeneralRe: How to test equality Pin
supercat91-Nov-09 14:27
supercat91-Nov-09 14:27 
GeneralRe: How to test equality Pin
Luc Pattyn1-Nov-09 14:33
sitebuilderLuc Pattyn1-Nov-09 14:33 
GeneralRe: How to test equality Pin
supercat91-Nov-09 15:45
supercat91-Nov-09 15:45 
GeneralRe: How to test equality Pin
Luc Pattyn1-Nov-09 16:00
sitebuilderLuc Pattyn1-Nov-09 16:00 
GeneralRe: How to test equality Pin
supercat91-Nov-09 18:01
supercat91-Nov-09 18:01 
GeneralRe: How to test equality Pin
Robert Surtees6-Nov-09 8:32
Robert Surtees6-Nov-09 8:32 
GeneralRe: How to test equality Pin
Nemanja Trifunovic10-Nov-09 12:37
Nemanja Trifunovic10-Nov-09 12:37 
GeneralString of Horror Pin
Izisin28-Oct-09 10:01
Izisin28-Oct-09 10:01 
GeneralRe: String of Horror Pin
Adam Maras28-Oct-09 11:42
Adam Maras28-Oct-09 11:42 
GeneralRe: String of Horror Pin
Jaime Olivares31-Oct-09 20:31
Jaime Olivares31-Oct-09 20:31 
GeneralRe: String of Horror Pin
dojohansen8-Jan-10 0:20
dojohansen8-Jan-10 0:20 
Generaltrying to figure out if number is negative Pin
Omar Gameel Salem26-Oct-09 2:19
professionalOmar Gameel Salem26-Oct-09 2:19 
GeneralRe: trying to figure out if number is negative Pin
J4amieC26-Oct-09 2:46
J4amieC26-Oct-09 2:46 
GeneralRe: trying to figure out if number is negative Pin
Jarek Kruza26-Oct-09 2:55
Jarek Kruza26-Oct-09 2:55 
GeneralRe: trying to figure out if number is negative Pin
Omar Gameel Salem26-Oct-09 3:21
professionalOmar Gameel Salem26-Oct-09 3:21 
GeneralRe: trying to figure out if number is negative Pin
Jarek Kruza26-Oct-09 3:31
Jarek Kruza26-Oct-09 3:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.