[Script Info]
Title:
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.07,0:00:05.23,Default,,0000,0000,0000,,If n is 123, count will end up as 3, which would be correct. There are three
Dialogue: 0,0:00:05.23,0:00:09.28,Default,,0000,0000,0000,,digits. If n is 100, count will end up as 2, which is not the correct number of
Dialogue: 0,0:00:09.28,0:00:15.85,Default,,0000,0000,0000,,digits. The loop condition should actually be. While temp is greater than or
Dialogue: 0,0:00:15.85,0:00:20.15,Default,,0000,0000,0000,,equal to 10. We can see this by hand tracing the code. The values I'm
Dialogue: 0,0:00:20.15,0:00:26.16,Default,,0000,0000,0000,,interested in are count and temp. If n starts out as 123, then count will start
Dialogue: 0,0:00:26.16,0:00:33.47,Default,,0000,0000,0000,,as 1, temp will start as 123. Temp is greater than 10, so we increment count.
Dialogue: 0,0:00:34.88,0:00:40.70,Default,,0000,0000,0000,,And divide temp by 10 and divide temp by 10.0 which will give us 12.3. Now, we
Dialogue: 0,0:00:40.70,0:00:45.98,Default,,0000,0000,0000,,go back to the loop condition. Temp is still greater then 10 so we increment
Dialogue: 0,0:00:45.98,0:00:51.93,Default,,0000,0000,0000,,the count and then divide temp by 10.0 again so we have 1.23. Now, when we
Dialogue: 0,0:00:51.93,0:00:55.83,Default,,0000,0000,0000,,check again, temp is less than 10. So we skip to the end, and we're done. But
Dialogue: 0,0:00:55.83,0:01:02.10,Default,,0000,0000,0000,,what would happen if n was 100? Count would start as 1, the way it did before.
Dialogue: 0,0:01:02.10,0:01:05.61,Default,,0000,0000,0000,,And temp would start as 100. Temp is greater than 10, so we would increment
Dialogue: 0,0:01:05.61,0:01:13.95,Default,,0000,0000,0000,,count and then divide temp by 10.0. So we would have 10. And then check the
Dialogue: 0,0:01:13.95,0:01:18.94,Default,,0000,0000,0000,,condition again. But this time, 10 is not greater than 10. It's equal, so it
Dialogue: 0,0:01:18.94,0:01:24.86,Default,,0000,0000,0000,,skips out immediately. When in fact, we still had two digits left. We needed to
Dialogue: 0,0:01:24.86,0:01:28.66,Default,,0000,0000,0000,,increment count again. This is why the condition should be temp is greater than
Dialogue: 0,0:01:28.66,0:01:30.19,Default,,0000,0000,0000,,or equal to 10.