Specifically, 1.4142135623730951 is the shortest decimal representation that rounds to the closest possible value to \sqrt{2} using standard 64-bit floating point.
Converting that 64-bit floating point number to a BigFloat doesn’t actually change its numerical value, but it does change how many digits are printed in the decimal representation you see. It’s the same as if you asked for a bunch of decimal digits from @printf:
julia> using Printf
julia> @printf("%.52f", sqrt(2))
1.4142135623730951454746218587388284504413604736328125
64-bit floating point only has about ~15 decimal digits worth of precision, which is why the shortest decimal needed to round to that is the length it is. You can see that this is the closest possible value by comparing it (and its nearest representable neighbors) to that higher-precision reference:
You can expect that the last digit is not correct and it’s not Julia-specific (max. 15-17 is correct for Float64, and fewer for Float32, or rather, exactly 53 bits after rounding, but any previous digit in binary or decimal can look off), even that the last few, and it’s not a bug per se. You can expect arbitrary many digits to be wrong for some numbers.
I myself once learned 380 digits of π, when I was a crazy high-school kid. My never-attained ambition was to reach the spot, 762 digits out in the decimal expansion, where it goes “999999”, so that I could recite it out loud, come to those six 9’s, and then impishly say, “and so on!”
This sequence of six nines is sometimes called the “Feynman point”, after physicist Richard Feynman
From correct value of pi at Wikipedia:
… 4999999837
julia> setprecision(640*ceil(Int, log(10)/log(2))); string(big(pi))[762:772] # some miscalculation in finding the cut-off point-in binary for the decimal, but showing correct
"34999999837"
You can see that if you end at 98 (correct) and then cut off that (8) decimal and round the previous up from that decimal, then you would get … 35000000 …
Nothing fundamentally different applies in binary. You could get arbitrary long series of 1s repeating in pi or sqrt(2) or other irrationals.* Or in decimal, arbitrary long series of 9s as shown.
I’m trying to hit that right spot, but BigFloat is binary big-floating point:
For any normal number you will get arbitrary long sequences, and even all know literature ever written encoded in pi. But only if pi is proved normal. I don’t know if it’s know for the square root of 2, for all I know it’s proven to NOT be normal. Still you could get very long series.
We do have Dec64, and Dec128, but no arbitrary-precision decimal floating point, that I know of, but it would neither help…