Why would a bike computer calculate distance accurately but average speed inaccurately? My otherwise reliable non-GPS bike computer calculates an extremely inaccurate average speed for my morning commutes. After my ride this morning, I read the following values from the display (units are in miles and miles per hour):


trip dist: 1.70
trip time: 00:06:29
avg speed: 16.47
max speed: 23.86


However, the actual average speed is: 1.7 / (6 / 60 + 29 / 3600) = 15.73. The reported value is off by almost 5%. This bothers me because I like to set goals to improve my average speed (for my traffic-light-enforced "interval training"), but the inaccuracy is higher than the 0.5 mph increments I reach for.

I would have assumed that a bike computer would compute average speed simply by dividing "trip dist" by "trip time"? What is it computing, and why is it different than the true average?

(slightly related: Why aren&#39;t average speeds computed over distance?)
Okay, this actually requires some knowledge of how these little computers work internally. Bicycle computers need to be extremely low-power, so the easiest way to do this is to make them very simple. Normal computers are able to use non-integer numbers. An integer is 1,2,3,4, etc., non-integer means for instance 1/2, 0.5762 or pi. Computers use so-called floating point numbers to represent non-integer numbers.

However, floating point numbers are very hard to use for these small computers compared to integers. So, they don't! They only use integers to do all necessary calculations, and with very little exceptions they are all limited to 8-bit integers. An 8-bit integer can store a value of 0-255. So, any calculation will (a) not be more precise than a whole number (e.g.: dividing 8 by 5 will yield 1 instead of 1.6 because you cannot represent numbers behind the decimal point) and (b) cannot exceed beyond the range of 0-255.

It's even worse: most bicycle computers can't even do math. Well, they can usually add and multiply, but they cannot divide or subtract. They are really super bare bones stuff, because they have to survive for a couple years on the juice in a single coin cell.

So, how does this affect the calculation of distance, speed and eventually average speed? Well, a bike computer has only 2 inputs: a very precise timer (usually outputting between 1024 and 32768 pulses per second) and a pulse input from a magnet on your wheel. It also knows how long the circumference of your wheel is. So, in order to calculate your current speed it does the following:


wait for a pulse from your wheel
start a timer
when the next wheel pulse arrives, stop the timer
divide your wheel circumference by the time and use a lookup table to convert this into something human-readable.


So, let's say the timer runs at 1024Hz and your bike wheel turns at about 5 rotations per second (36km/h or 22mph). This would mean that you would count floor(1024/5)=204 timer ticks per wheel rotation. In the little processor is a lookup table that relates those 204 ticks to your specific wheel size (which you programmed in) and then finds what speed needs to be displayed on your screen. It doesn't actually calculate it, because it's very hard for that processor to do such things. Besides, this table only needs to be a couple wheel sizes by a few tens or maybe 100 different time values. For instance a 5x100 table, pretty small in computer terms. 

Distance is very easy to calculate: just multiply wheel circumference by the number of rotations. Then use another lookup table to relate this to something displayable. This too only requires a small lookup table.

However, average speed is not something that can be put into a reasonable-size lookup table. There are just too many possible trip distance and trip time values that can occur. So these computers have to cheat somehow: either they need to use the very limited math capabilities they have, or they need to round some things down or look for the nearest average value. This is exactly what your bike computer is doing. 

There are more advanced bicycle computers, especially nowadays. With older designs, you could really see this lookup table-nature of operation: it could display for instance 22.3 km/h and 22.5, but not 22.4. Why? It was not in the lookup table. No matter how hard you would try to ride exactly at 22.4 km/h, it would never actually display this value. Also, older designs would only allow you to enter the inch-size of your tires, not the actual precise circumference in mm. 

Nowadays, there are actually bike computers that can handle more 'complex' mathematical operations and use better number representations (either 16-bit integers or floating point numbers) to get to a better estimate of your speed and averages.