15,849,030 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 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
 Re: How to test equality supercat91-Nov-09 14:27 supercat9 1-Nov-09 14:27
 PJ Arends wrote: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);. If I am testing multiple bits, I will either explicitly test for being unequal to zero, or being equal to a particular number (depending upon whether the requirement is that at least one bit be set, or that all bits be set). I do not like the syntax you seem to favor, since its normal semantic meaning requires that the same constant appear on both halves of the comparison operator; if the two halves get edited out of sync, the code will break.
 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
 Re: String of Horror Jaime Olivares31-Oct-09 20:31 Jaime Olivares 31-Oct-09 20:31
 Re: String of Horror dojohansen8-Jan-10 0:20 dojohansen 8-Jan-10 0:20
 trying to figure out if number is negative Omar Gameel Salem26-Oct-09 2:19 Omar Gameel Salem 26-Oct-09 2:19
 Re: trying to figure out if number is negative J4amieC26-Oct-09 2:46 J4amieC 26-Oct-09 2:46
 Re: trying to figure out if number is negative Jarek Kruza26-Oct-09 2:55 Jarek Kruza 26-Oct-09 2:55
 Re: trying to figure out if number is negative Omar Gameel Salem26-Oct-09 3:21 Omar Gameel Salem 26-Oct-09 3:21
 Re: trying to figure out if number is negative Jarek Kruza26-Oct-09 3:31 Jarek Kruza 26-Oct-09 3:31
 Re: trying to figure out if number is negative Omar Gameel Salem26-Oct-09 4:06 Omar Gameel Salem 26-Oct-09 4:06
 Re: trying to figure out if number is negative AspDotNetDev30-Oct-09 18:08 AspDotNetDev 30-Oct-09 18:08
 Last Visit: 31-Dec-99 19:00     Last Update: 29-Feb-24 10:52 Refresh ᐊ Prev1...588589590591592593594595596597 Next ᐅ