我试图在我的代码中评估以下示例,但得到错误的答案:
julia> -1.259237254330301e-29*10^29
-9.930838679817422e-11
Run Code Online (Sandbox Code Playgroud)
答案显然是错误的,预计-1.259237254330301.我得到了正确的答案
julia> -1.259237254330301e-29*1e29
-1.2592372543303008
Run Code Online (Sandbox Code Playgroud)
有谁知道原因?
考虑以下朱莉娅的例子
function f(x::Array{Real,1}, y::Real)
return [x..., y]
end
arr = [1,2,3]
f(arr, 4.0)
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我收到以下错误
ERROR: LoadError: MethodError: no method matching f(::Array{Int64,1},
::Float64)
Closest candidates are:
f(::Array{Real,1}, ::Real) at ...
Run Code Online (Sandbox Code Playgroud)
有没有什么办法解决这一问题?
julia ×2