小编kip*_*820的帖子

splat的解释

http://learnxinyminutes.com/docs/julia/上阅读Julia时,我发现了这个:

# You can define functions that take a variable number of
# positional arguments
function varargs(args...)
    return args
    # use the keyword return to return anywhere in the function
end
# => varargs (generic function with 1 method)

varargs(1,2,3) # => (1,2,3)

# The ... is called a splat.
# We just used it in a function definition.
# It can also be used in a fuction call,
# where it will splat an Array or Tuple's …
Run Code Online (Sandbox Code Playgroud)

arrays tuples splat julia

8
推荐指数
1
解决办法
2298
查看次数

了解BigInt的使用

我很难理解如何BigInt正确使用.在我看来,应该使用BigInt何时Int64Int128不够,并且显然BigInt使用任意精度算术(我不知道).

假设我想计算一些大数的阶乘,例如30.我不知道需要存储多少位factorial(30)但两者都要

test = Int128
test = factorial(30)
Run Code Online (Sandbox Code Playgroud)

test = BigInt
test = factorial(30)
Run Code Online (Sandbox Code Playgroud)

产生-8764578968847253504明显不正确的产品.

根据Julia lang文档,似乎通常的数学运算符是为这种类型定义的(BigInt),结果被提升为a BigInt.因此,我没有看到我做错了什么,我显然误解了一些事情.希望你们中的一些人可能对我有一个解释:)

PS:如果有话要说,我正在运行64位版本的Windows 7

bigint julia

6
推荐指数
1
解决办法
2378
查看次数

标签 统计

julia ×2

arrays ×1

bigint ×1

splat ×1

tuples ×1