# The ending never-ending loop

• Probably you've seen this in more than one variation, but I liked this one.

`double a = 1;for(double b=0;b < a; b++){    a++;}`

What o what goes wrong here?

•  It's not quite a never-ending loop. Once a gets above about 2^53 the increment won't change it, so b will catch up.

• This has been Photoshopped.

•

• TRWTF is using floats for a loop counter in the first place.

• @morbiuswilters said:

This has been Photoshopped.

Now that you mention it.... the blue color on the sleeve of your avatar doesn't seem to match with the color of the vest...

• Shriley the loop will never be used since b starts off as < a. Or am I missing some in joke?

• @NeoMojo said:

Shriley the loop will never be used since b starts off as < a.
Programming 101 - the loop continues while the condition is true, not false. If it helps, here it is as a while loop:

`double a = 1;double b = 0;`
`while(b < a){    a++;`
`    b++;`
`}`

•  oh, yeah, hence ending never-ending loop

• @NeoMojo said:

Shriley the loop will never be used since b starts off as < a. Or am I missing some in joke?

You're missing something far, far worse: an understanding of basic for loops.

• @NeoMojo said:

oh, yeah, hence ending never-ending loop
In theory.

As pointed out previously, in reality, since they're floats, there'll come a time when the limitatation of the floating point format means that the number is large enough that adding one won't actually change the value, so a will equal b. (Alternatively, with integers, a will roll round just before b, making b > a.)

• And as floating point calculations differ from machine to machine it fill the requirements.

It delays execution depending on the running machine.

• @bstorer said:

@NeoMojo said:

Shriley the loop will never be used since b starts off as < a. Or am I missing some in joke?

You're missing something far, far worse: an understanding of basic for loops.
Awesome. After Visual Basic for Applications Micosoft has finally released Visual Basic for Loops. The perfect tool to let highly-paid consultants play without giving them a chance to do any real damage. All-new ability to store your loops in an Access database! Order today.

• @NeoMojo said:

Shriley the loop will never be used since b starts off as < a. Or am I missing some in joke?

TRWTF is that you don't know how to properly misspell "surely".

• @A Wizard A True Star said:

TRWTF is that you don't know how to properly misspell "surely".
Are you trolling or are you not getting the reference?

•  Please provide a non You-Tube link so that I may view all of the Shriley goodness at work.

Thank you,

The Management

• @A Wizard A True Star said:

@NeoMojo said:

Shriley the loop will never be used since b starts off as < a. Or am I missing some in joke?

TRWTF is that you don't know how to properly misspell "surely".
Maybe he meant "shrilly," as in "the loop will never be used in a shrill manner."  Of course, I have absolutely no idea what that means.

• @Zecc said:

@A Wizard A True Star said:
TRWTF is that you don't know how to properly misspell "surely".
Are you trolling or are you not getting the reference?

Did you not notice the OP incorrectly misspelt surely, Shriley, instead of Shirley?

• @PJH said:

@Zecc said:
@A Wizard A True Star said:
TRWTF is that you don't know how to properly misspell "surely".
Are you trolling or are you not getting the reference?

Did you not notice the OP incorrectly misspelt surely, Shriley, instead of Shirley?

I completely misread and subsequently misunderstood A.W.A.T.S.' comment.

I apologize and retreat in shame.

•  @amischiefr said:

Please provide a non You-Tube link so that I may view all of the Shriley goodness at work.

Thank you,
The Management

Ted Striker:
Surely you can't be serious.

Rumack:
I am serious... and don't call me Shirley.

--Airplane! (1980)

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.