Fix #3 and #4 by explicitly extending sign for negative values.