在元组 Julia 中推一个大浮点数
pushing a big float inside a tuple Julia
我正在尝试将一个大的浮点数“推”到一个元组中。但是出现以下错误:
# where test() is a function with big floats as values
store = Tuple{Any, Any}][]
for i in 1:10
push!(store, test(i))
end
store
错误消息提到 convert()
作为解决方案,但我不确定如何转换 test()
。
您不能将 BigFloat
推送到仅接受 Tuples
的容器中。您的容器必须改为接受 BigFloat
s,因此请使用:
对其进行初始化
store = BigFloat[]
另请注意,您可以只写:
store = test.(1:10)
我正在尝试将一个大的浮点数“推”到一个元组中。但是出现以下错误:
# where test() is a function with big floats as values
store = Tuple{Any, Any}][]
for i in 1:10
push!(store, test(i))
end
store
错误消息提到 convert()
作为解决方案,但我不确定如何转换 test()
。
您不能将 BigFloat
推送到仅接受 Tuples
的容器中。您的容器必须改为接受 BigFloat
s,因此请使用:
store = BigFloat[]
另请注意,您可以只写:
store = test.(1:10)