Click here to Skip to main content
14,921,361 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: Magic C++ Program Pin
BillW338-Sep-08 8:57
professionalBillW338-Sep-08 8:57 
GeneralRe: Magic C++ Program Pin
The Cake of Deceit8-Sep-08 11:03
MemberThe Cake of Deceit8-Sep-08 11:03 
GeneralRe: Magic C++ Program Pin
peterchen8-Sep-08 11:27
Memberpeterchen8-Sep-08 11:27 
GeneralRe: Magic C++ Program Pin
Emil - Gabriel15-Sep-08 3:25
MemberEmil - Gabriel15-Sep-08 3:25 
Generalhow many seconds? Pin
tommyligo7-Sep-08 6:43
Membertommyligo7-Sep-08 6:43 
GeneralRe: how many seconds? Pin
Megidolaon7-Sep-08 20:41
MemberMegidolaon7-Sep-08 20:41 
GeneralRe: how many seconds? Pin
CPallini8-Sep-08 0:06
mveCPallini8-Sep-08 0:06 
GeneralRe: how many seconds? Pin
Robert.C.Cartaino8-Sep-08 5:12
MemberRobert.C.Cartaino8-Sep-08 5:12 
CPallini wrote:

<code>long TotalMilliSeconds = gettime(); // number of milliseconds since September 1st, 1970.</code>
for (i=0; i<Total<code>Milli</code>Seconds; i++)
{
  <code>MilliSeconds++;</code>
  <code>if (MilliSeconds == 1000)</code>
  <code>{</code>
    <code>MilliSeconds = 0;</code>
    Seconds++;
    if ( Seconds == 60)
    {
      Seconds = 0;
      Minutes++;
      if (Minutes == 60)
      {
        Minutes = 0;
        Hours++:
      }
    }
  }
}



Ooo, I like that. Did your company receive a bug report about that "clock application" they wrote (I added the relevant code above in Red)?

SPR: #8327
PROBLEM DESCRIPTION: My clock application takes 100% CPU and doesn't update every second.
LIKELY CAUSE: long timespan = gettime(); // number of milliseconds since September 1st, 1970.

SOLUTION:
Your clock is running through 1,199,836,800,000 (1.2 trillion) iterations per second, you dumba**.
GeneralRe: how many seconds? Pin
CPallini8-Sep-08 8:15
mveCPallini8-Sep-08 8:15 
GeneralRe: how many seconds? Pin
BillW338-Sep-08 6:27
professionalBillW338-Sep-08 6:27 
GeneralRe: how many seconds? Pin
CPallini8-Sep-08 8:17
mveCPallini8-Sep-08 8:17 
GeneralRe: how many seconds? Pin
BillW338-Sep-08 13:56
professionalBillW338-Sep-08 13:56 
GeneralRe: how many seconds? Pin
peterchen8-Sep-08 11:29
Memberpeterchen8-Sep-08 11:29 
GeneralCoding Pin
mistyangel6-Sep-08 23:30
Membermistyangel6-Sep-08 23:30 
GeneralRe: Coding Pin
enhzflep7-Sep-08 1:39
Memberenhzflep7-Sep-08 1:39 
GeneralRe: Coding Pin
Paul Conrad7-Sep-08 5:21
professionalPaul Conrad7-Sep-08 5:21 
GeneralTHIS QUESTION IS THE HORROR Pin
leckey7-Sep-08 6:57
Memberleckey7-Sep-08 6:57 
GeneralRe: Coding Pin
Dan Neely8-Sep-08 2:22
MemberDan Neely8-Sep-08 2:22 
GeneralRe: Coding Pin
BillW338-Sep-08 5:08
professionalBillW338-Sep-08 5:08 
GeneralLooking at this math is making me num... Pin
AeonBlue4-Sep-08 8:29
MemberAeonBlue4-Sep-08 8:29 
GeneralRe: Looking at this math is making me num... Pin
Pete O'Hanlon4-Sep-08 9:12
mvePete O'Hanlon4-Sep-08 9:12 
GeneralRe: Looking at this math is making me num... Pin
AeonBlue4-Sep-08 9:33
MemberAeonBlue4-Sep-08 9:33 
GeneralRe: Looking at this math is making me num... Pin
dighn4-Sep-08 11:02
Memberdighn4-Sep-08 11:02 
GeneralRe: Looking at this math is making me num... Pin
BillW338-Sep-08 4:56
professionalBillW338-Sep-08 4:56 
GeneralRe: Looking at this math is making me num... Pin
CPallini7-Sep-08 21:43
mveCPallini7-Sep-08 21:43 

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.