Click here to Skip to main content
15,891,423 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: A little tiny horror Pin
jhwurmbach8-Jan-08 23:59
jhwurmbach8-Jan-08 23:59 
JokeRe: A little tiny horror Pin
Robert Surtees9-Jan-08 7:11
Robert Surtees9-Jan-08 7:11 
GeneralRe: A little tiny horror Pin
Gary Wheeler15-Jan-08 0:32
Gary Wheeler15-Jan-08 0:32 
GeneralRe: A little tiny horror Pin
CPallini9-Jan-08 7:35
mveCPallini9-Jan-08 7:35 
GeneralRe: A little tiny horror Pin
Gary Wheeler9-Jan-08 0:30
Gary Wheeler9-Jan-08 0:30 
GeneralRe: A little tiny horror Pin
CPallini9-Jan-08 3:14
mveCPallini9-Jan-08 3:14 
Generalit might calculate it wrong Pin
peterchen9-Jan-08 12:48
peterchen9-Jan-08 12:48 
GeneralRe: it might calculate it wrong Pin
Notorious_pd16-Jan-08 7:20
Notorious_pd16-Jan-08 7:20 
That is the first thing I thought of when I saw this. The thought of converting floating point to integers using casts keeps me awake at night.

I am actually currently working on a project at work that has a few of these. I just started here at the time I noticed them. For fun, I thought it would be neat to try compiling this project (which was developed in VC++ 6.0) with VC 2005, and VC 2005 choked on these instances. Good job to the compiler team on that one. It also choked on a few things that I thought VC++ 6.0 should have, such as assigning an int literal to a CString. A few more bonus points to the team there, although 6.0 definitely should have caught that.

Of the pow(int,int)s, at least one could've used the x *= 2 form, as it was in a loop, and the others the shift form. In the end, I decided not to touch any of them, because for all I know the truncation does mess things up but somebody spent a bunch of hours putting in "fixes" to work around this. The routines in question don't seem to have any bugs for now, but since a lot of the other ones do, I decided to focus my energy on those.
GeneralRe: A little tiny horror Pin
leppie8-Jan-08 22:20
leppie8-Jan-08 22:20 
GeneralRe: A little tiny horror Pin
Robert Rohde8-Jan-08 22:27
Robert Rohde8-Jan-08 22:27 
GeneralRe: A little tiny horror Pin
leppie9-Jan-08 1:45
leppie9-Jan-08 1:45 
GeneralRe: A little tiny horror Pin
Gary Wheeler9-Jan-08 0:40
Gary Wheeler9-Jan-08 0:40 
JokeRe: A little tiny horror Pin
KarstenK8-Jan-08 22:59
mveKarstenK8-Jan-08 22:59 
GeneralRe: A little tiny horror Pin
Gary Wheeler9-Jan-08 0:32
Gary Wheeler9-Jan-08 0:32 
JokeRe: A little tiny horror Pin
leppie9-Jan-08 1:57
leppie9-Jan-08 1:57 
JokeNope Pin
CPallini9-Jan-08 2:22
mveCPallini9-Jan-08 2:22 
GeneralRe: Nope Pin
leppie9-Jan-08 2:46
leppie9-Jan-08 2:46 
GeneralRe: A little tiny horror PinPopular
Tim Smith9-Jan-08 10:08
Tim Smith9-Jan-08 10:08 
GeneralRe: A little tiny horror Pin
leppie9-Jan-08 10:14
leppie9-Jan-08 10:14 
JokeRe: A little tiny horror Pin
CPallini10-Jan-08 3:06
mveCPallini10-Jan-08 3:06 
JokeRe: A little tiny horror Pin
CPallini9-Jan-08 2:25
mveCPallini9-Jan-08 2:25 
GeneralRe: A little tiny horror Pin
ClementsDan10-Jan-08 15:11
ClementsDan10-Jan-08 15:11 
GeneralRe: A little tiny horror Pin
Tim Carmichael14-Jan-08 8:59
Tim Carmichael14-Jan-08 8:59 
JokeRe: A little tiny horror Pin
RichardM114-Jan-08 10:15
RichardM114-Jan-08 10:15 
GeneralRe: A little tiny horror PinPopular
Pete O'Hanlon14-Jan-08 9:31
mvePete O'Hanlon14-Jan-08 9: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.