Squaring of distance and converting types to double