Ask Your Question

Revision history [back]

sqrt(2).n(digits=4) returns a number which agrees with sort(2) to 4 digits of precision, but it need not be obtained by truncating sqrt(2) after 4 digits. I'm guessing that it's obtained by truncating sqrt(2) after the necessary number of binary digits:

sage: a = sqrt(2).n(digits=4)
sage: a.n(digits=30)
1.41421508789062500000000000000

sage: b = sqrt(2).n(16)
sage: b.n(digits=30)
1.41421508789062500000000000000
sage: a == b
True