If you want to match NOAA, you'll have to consult Jean Meeus' Astronomical Algorithms (mostly Chapter 15). And it's complicated! Martin Beckett is correct, you have to define the sunset. Typically this is the apparent rise or set of upper limb of the sun, which makes your "standard" altitide -5/6 degrees (not zero). And you can't calculate the sunrise or sunset directly with NOAA's accuracy. You'll have to create a governing set of equations for apparent right ascension and declination for the day in question and then interpolate the apparent right ascension and declination over time to find the exact rising and setting times at the standard altitude.
Hope this helps. I spent about a month digesting AA and re-writing all our solar code when I came across the same thing, and it still took over a year to sort out some of the corner cases where my code broke. So it will take some time to figure out. I'm not aware of any public code examples of this algorithm and don't have any to share at this moment, but I'm happy to help you through some headaches if I can.