Steps to seconds
transcript
You counted the steps. Now turn them into time. One division does it. Round up.
Almost five billion steps. A hundred thousand steps each millisecond. Divide the steps by the rate. Fifty thousand milliseconds.
Fifty thousand milliseconds is fifty seconds. The limit is one second. It is fifty times over. It does not fit.
Always round up. A part of a millisecond still costs time. Add the rate minus one, then divide. That rounds up without a decimal.
The rate is an estimate. Machines and languages differ. Keep a margin of three. Measure when it is close.
Some counts overflow even sixty four bits. N cubed overflows past two million. Two to the n overflows past sixty two. Cap the count before you multiply. A capped count is still over any budget.
Step counts grow fast. N squared at a hundred thousand is ten billion. That is above the thirty two bit limit. Use sixty four bit integers.
Steps divided by rate. Full breakdown in the lecture.