how can i show an irrational number to 100 decimal places in python?

后端 未结 4 1467
孤城傲影
孤城傲影 2020-12-03 03:38

I am trying to find the square root of 2 to 100 decimal places, but it only shows to like 10 by default, how can I change this?

4条回答
  •  臣服心动
    2020-12-03 03:57

    You can use gmpy2.

    import gmpy2
    ctx = gmpy2.get_context()
    ctx.precision = 300
    print(gmpy2.sqrt(2))
    

提交回复
热议问题