Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Is it too much to ask a computer to do do 2 billion iterations of a single assignment?

I mean with a 2 GHz clock, the CPU can do 2 billion instructions per second, so theoretically a single for loop with a single assignment will have: 1 comparison, 2 assignments and 1 branch per iteration. That shouldn't be too much to ask from a computer right? Then why has the computer been executing this loop for over 10 minutes?

PS: the language is tcl.

Update:

There is no way to make a mistake in a single line loop like this:

for {set i 0} {$i < 2147483648} {incr i} {

set arr($i) $i

}

1 Answer

Relevance
  • DOCTOR
    Lv 5
    8 years ago
    Favorite Answer

    You made a mistake in the loop, and that why it is taking so long.

Still have questions? Get your answers by asking now.