Fixed floating-point errors due to use of float where double needed