Balusters split the opening into one more gap than there are balusters, because there is a gap against each post as well as between balusters. With n balusters of width w in a clear opening O, every gap is (O − n × w) ÷ (n + 1).
The code test is a ball: a 4 in sphere must not pass anywhere. A gap of exactly 4 in does not pass, because the ball just fits through it. So the calculator finds the smallest n that makes every gap smaller than your limit, then spaces everything equally. On-centre spacing is the baluster width plus the gap, which is the number you step off with a tape. A gap that creeps over by an eighth of an inch is the one that fails the inspection and gets the railing pulled apart, so the calculator never hands you one.
To space spindles on a deck, mark the first gap from the post, then step off the on-centre spacing along the rail: baluster, gap, baluster, gap. Every gap is equal, so the last one lands on the far post with no fudging. A spindle is just another name for a baluster, so the same sum works as a deck railing spindle spacing calculator, and with the stair guard chip it sets banister spindle spacing on a stair.
The railing sits on a deck or beside a stair, so size those first with the deck calculator and the stair calculator. Before the posts go in, the squaring calculator checks that the layout is square.