Bug with astronomical coordinate conversion

As part of a bigger project, I'm developing a JavaScript library that will help me generate ephemerides for pretty much whatever you want. The current piece I'm working on is coordinate conversion. As a tester project, I'm generating a list of degrees ON the ecliptic (that is, longitude 34, latitude 0) and their corresponding horizontal azimuths for a given time and place. The problem I'm getting is that in the middle, between ecliptic degree 155 and 334, all the azimuth jump into the 20000 range. What's going wrong?