Fix handling of negative values in tosw().