Error Diffusion

How to calculate the error in error diffusion? Can you give an example?

Although this isn’t OpenGL related:

error = (what you put in the pixel) minus (what should have been in the pixel).

Dithering is fairly well covered in typical graphics reference books, such as Foley, van Dam et al.