Zero Crossing of a Noisy Sine Wave I'm trying to find the zero crossings of a sine wave to transform the sine wave into a square wave. The only problem is that the sine wave is noisy, so I'm getting lots of jitter and false zero crossings.

Can anyone recommend any simple psuedocode or relevant materials? So far I have something like this:

 if (sample[i]>0 &amp;&amp; sample[i+1]&lt;0) || (sample[i]&lt;0 &amp;&amp; sample[i+1]>0) 

Can anyone recommend a more robust method?
You could try low-pass filtering the input signal to get smoother zero-crossings (or even band-pass filtering if you have a good idea of the frequency location of the sine wave). The risk is that if sample-accurate phase information is essential to your application, the additional lag from the filter might be a problem.

Another approach: instead of trying to transform the sine wave into a square wave, what about getting an independent square wave oscillator to align itself in phase/frequency with the sine wave? This can be done with a phase-locked loop.