What's wrong with my computation of the intersection of a ray with a sphere
This line doesn't look quite right:

float t = (-b - sqrt (det)) / 2.0 * a;


You're missing parentheses around (2.0 * a). Remember that multiplication and division have equal operator precedence, so the expression as it's currently written means ((-b - sqrt (det)) / 2.0) * a, putting the a in the numerator instead of the denominator.

(Oh and this is a nitpick, but the thing you named det is called a “discriminant”, not a determinant.)