solving bug of floating point calculation