15,849,105 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.

 Re: How to test equality dojohansen8-Jan-10 0:16 dojohansen 8-Jan-10 0:16
 Re: How to test equality Jeroen De Dauw28-Oct-09 12:44 Jeroen De Dauw 28-Oct-09 12:44
 Re: How to test equality Super Lloyd29-Oct-09 15:14 Super Lloyd 29-Oct-09 15:14
 Re: How to test equality supercat930-Oct-09 10:26 supercat9 30-Oct-09 10:26
 Re: How to test equality Richard MacCutchan31-Oct-09 1:06 Richard MacCutchan 31-Oct-09 1:06
 Re: How to test equality OriginalGriff31-Oct-09 1:51 OriginalGriff 31-Oct-09 1:51
 Re: How to test equality supercat91-Nov-09 14:47 supercat9 1-Nov-09 14:47
 Re: How to test equality PJ Arends1-Nov-09 8:39 PJ Arends 1-Nov-09 8:39
 Actually, I would use `bitVar = ((byteVar & 0x40) == 0x40);`. Using the `!= 0` or in your case the `!!` style will work if you are comparing a single bit, but it will break if you are comparing multiple bits: `bitVar = ((byteVar & 0x41) == 0x41);` is not the same as `bitVar = ((byteVar & 0x41) != 0);`. You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!
 Re: How to test equality supercat91-Nov-09 14:27 supercat9 1-Nov-09 14:27
 Re: How to test equality Luc Pattyn1-Nov-09 14:33 Luc Pattyn 1-Nov-09 14:33
 Re: How to test equality supercat91-Nov-09 15:45 supercat9 1-Nov-09 15:45
 Re: How to test equality Luc Pattyn1-Nov-09 16:00 Luc Pattyn 1-Nov-09 16:00
 Re: How to test equality supercat91-Nov-09 18:01 supercat9 1-Nov-09 18:01
 Re: How to test equality Robert Surtees6-Nov-09 8:32 Robert Surtees 6-Nov-09 8:32
 Re: How to test equality Nemanja Trifunovic10-Nov-09 12:37 Nemanja Trifunovic 10-Nov-09 12:37
 String of Horror Izisin28-Oct-09 10:01 Izisin 28-Oct-09 10:01