Accuracy of std::sqrt double vs float

OPEN

I was wondering if there is any difference in accuracy between the float and double precision sqrt function for float inputs/outputs?

I.e. is there any input for which sqrt1 and sqrt2 produce different results in the code below?

float input = get_input(); //Get an arbitrary float number
float sqrt1 = std::sqrtf(input);
float sqrt2 = static_cast<float>(std::sqrt(static_cast<double>(input)));

Posted Dec 3, 2025, 10:05 AM UTC

611

Comments aren't archived yet

This post had 11 comments on Reddit. Comments for this period haven't been loaded into the archive yet.