简体   繁体   English

在元组 Julia 中推动一个大浮点数

[英]pushing a big float inside a tuple Julia

I am trying to "push" a big float into a Tuple.我试图将一个大浮点数“推”到一个元组中。 But get following error:但得到以下错误:

# 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

在此处输入图片说明

The error message mentions convert() as a solution, but I am not sure how to convert test() .错误消息提到convert()作为解决方案,但我不确定如何转换test()

You cannot push BigFloat into a container that accepts only Tuples .你不能推BigFloat到接受只是一个容器Tuples Your container has to accept BigFloat s instead, so initialize it with:你的容器必须接受BigFloat s,所以初始化它:

store = BigFloat[]

Also note that you could have just written:另请注意,您可以只写:

store = test.(1:10)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM