The exactness comes from two choices: compare squared distances and update with rational means. That keeps this one step in the exact register.

highlighted = computed this step

Why squared distance

Squared distance preserves the same nearest-centroid order as distance, but it avoids square roots. In this dataset the shown d^2 values are integers.

d2 comparison is exactd^2\text{ comparison is exact}
Exact distance and mean rulesOne step uses squared distance and exact means.k-means assignment tabletie: equal d^2 uses lowest centroid index; empty clusters rejectpointd^2 to c1=(1,1)d^2 to c2=(7,7)assigned(0,0)298c1(2,0)274c1(0,2)274c1(6,6)502c2(6,8)742c2(8,6)742c2new centroids: c1'=(2/3,2/3), c2'=(20/3,20/3)one exact centroid updateold c1=(1,1)old c2=(7,7)new c1=(2/3,2/3)new c2=(20/3,20/3)squares are old centroids; diamonds are exact means after one update

Why the mean stays exact

Each updated coordinate is a sum divided by the assigned count. That gives 2/3 on the left and 20/3 on the right.

new coordinates=2/3,20/3\text{new coordinates}=2/3,20/3
Exact distance and mean rulesOne step uses squared distance and exact means.k-means assignment tabletie: equal d^2 uses lowest centroid index; empty clusters rejectpointd^2 to c1=(1,1)d^2 to c2=(7,7)assigned(0,0)298c1(2,0)274c1(0,2)274c1(6,6)502c2(6,8)742c2(8,6)742c2new centroids: c1'=(2/3,2/3), c2'=(20/3,20/3)one exact centroid updateold c1=(1,1)old c2=(7,7)new c1=(2/3,2/3)new c2=(20/3,20/3)squares are old centroids; diamonds are exact means after one update

Summary

The distance comparison and centroid update are both exact arithmetic. No decimal approximation is needed for this step.

integer d2 and rational means\text{integer }d^2\text{ and rational means}
Exact distance and mean rulesOne step uses squared distance and exact means.k-means assignment tabletie: equal d^2 uses lowest centroid index; empty clusters rejectpointd^2 to c1=(1,1)d^2 to c2=(7,7)assigned(0,0)298c1(2,0)274c1(0,2)274c1(6,6)502c2(6,8)742c2(8,6)742c2new centroids: c1'=(2/3,2/3), c2'=(20/3,20/3)one exact centroid updateold c1=(1,1)old c2=(7,7)new c1=(2/3,2/3)new c2=(20/3,20/3)squares are old centroids; diamonds are exact means after one update