If you are sure you haven't made a mistake, the "negative variance" could be due to round-off error. I suppose you are using the textbook formula based on the sum of the X's and the sum of their squares. If so, try this instead.
First compute .
Then compute .