我在Pluto notebook中编写了以下代码
begin
function newton_sqrt(x,error_margin)
a=x/2
e=abs(a-x/a)
while e>error_margin
a=(a+x/a)/2
e=abs(a-x/a)
end
println(a)
end
print("Input an integer: ")
x = BigFloat(readline())
newton_sqrt(x,0.0001)
end我收到一个错误"ArgumentError: cannot parse“as BigFloat”。我无法接受提示符的输入。
我们对任何帮助都深表感谢。
发布于 2020-09-06 21:45:49
也许您应该使用下面这样的代码(我用##分隔Pluto单元):
using PlutoUI
##
@bind s TextField()
##
res = (s=="" ? "" : sqrt(BigFloat(s)))
##
md"The values of s is $s and the value of res is $res"

https://stackoverflow.com/questions/63763586
复制相似问题