fixed problem in case of minimal negative value (both for 16bit and 32bit).