Fix Clang warnings about warning: implicit conversion loses integer precision [-Wconversion] and
implicit casting.
Fix Clang warning about comparing floating point with == or != is unsafe [-Wfloat-equal]