fixed warning and changed 2s complement comparison to work with double.